【发布时间】:2019-04-26 14:44:27
【问题描述】:
我已经尝试了所有答案,但我遇到了类似的错误
main.js:2 未捕获的 ReferenceError:未定义导出
当我使用 compile to es5 作为目标时
和
Uncaught SyntaxError: Unexpected token {
当我使用 compile to es6 作为目标时
main.ts
import {MyLib} from './mylib';
let myLib = new MyLib("Anonymous", "Someone");
console.warn(myLib);
mylib.ts
export class MyLib {
constructor(public a: String, public b: String) {
}
toString() {
return "library tostring: " + this.a + " " + this.b;
}
}
tsconfig.json
{
"compilerOptions": {
"target": "es6",
"sourceMap": true
},
"exclude": [
"node_modules"
]
}
index.html
<html>
<head>
<title>
ts-demo !!
</title>
<script type="module" src="./require.js"></script>
<script type="module" src="./system.min.js"></script>
<script src="./tsdemo/main.js"></script>
</head>
<body>
</body>
</html>
【问题讨论】:
标签: javascript typescript requirejs phpstorm webstorm