【发布时间】:2020-06-15 04:25:39
【问题描述】:
我正在尝试使用 KonvaJS,我选择通过 npm 安装它。所以,正如https://konvajs.org/docs/index.html 中提到的,我使用了“npm install konva”,一切看起来都不错。我像这样在 index.js 中导入了 Konva:
import Konva from 'konva';
我的 index.js 与我的 index.html 相关,在正文的末尾有一个 script 标签:
<script type="text/javascript" src="./index.js"></script>
当我尝试打包 index.html 时,我收到“Uncaught TypeError: _konva.default.stage is not a constructor”。
当然,页面上没有出现任何与 Konva 相关的内容,因为错误位于第 5 行:const stage = new Konva.stage({
我读了https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_a_constructor,但我真的不明白我的错误在哪里。 (我也看到了https://github.com/konvajs/konva/issues/598,但我不使用 TypeScript。)
【问题讨论】:
标签: javascript import konvajs