我有一个非常简单的 webpack 项目,使用 Html 插件从单个 js 文件条目生成 html 文件。
我使用“npm install c3”安装了 c3
图表.js
import * as c3 from "c3";
var chart = c3.generate({
bindto: '#chart',
data: {
columns: [
['data1', 30, 200, 100, 400, 150, 250],
['data2', 50, 20, 10, 40, 15, 25]
]
}
});
当我加载页面时出现错误:
bootstrap:893 TypeError: c3.generate is not a function
at chart.js:5
at chart.js:14
__webpack_require__.oe @ bootstrap:893
Promise.catch (async)
./client/chart.js @ chart.js:14
__webpack_require__ @ bootstrap:769
fn @ bootstrap:129
6 @ module.js:22
__webpack_require__ @ bootstrap:769
(anonymous) @ bootstrap:907
(anonymous) @ bootstrap:907
chart.js:5 Uncaught (in promise) TypeError: c3.generate is not a function
at chart.js:5
at chart.js:14
(anonymous) @ chart.js:5
(anonymous) @ chart.js:14
Promise.catch (async)
./client/chart.js @ chart.js:14
__webpack_require__ @ bootstrap:769
fn @ bootstrap:129
6 @ module.js:22
__webpack_require__ @ bootstrap:769
(anonymous) @ bootstrap:907
(anonymous) @ bootstrap:907
我的 package.json 包含
"dependencies": {
"@types/c3": "^0.7.4",
"c3": "^0.7.12",
非常感谢任何建议。 c3js.org 没有提供如何 npm 安装和使用 ES6 导入的说明。
谢谢
最佳答案
已修复:
-从“c3”导入 * 作为 c3
+从“c3”导入 c3
关于javascript - 安装 c3 以在带有 ES6 导入的 webpack 项目中使用的正确步骤是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59841475/