【发布时间】:2020-08-19 08:47:05
【问题描述】:
我创建了纯打字稿项目,但导入/导出有问题。我在控制台“ReferenceError:未定义导出”中有错误。运行 tsc 命令后,我通过 Visual Studio 代码中的“Go live”扩展打开项目。
这是我的代码:
tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"lib": ["dom", "es2015", "es5", "es6"],
"sourceMap": true,
"outDir": "dist",
"strict": true,
"esModuleInterop": true
}
}
index.ts:
import { BoardUI } from './app/BoardUI';
const boardUI = new BoardUI();
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="shortcut icon" href="favicon.png" />
</head>
<body>
<h1>hello</h1>
<script type="module" src="../dist/index.js"></script>
</body>
</html>
【问题讨论】:
标签: javascript typescript