安装带有ES6导入的webpack项目中使用的c3的正确过程是什么?

问题描述 投票:0回答:1

我有一个非常简单的Webpack项目,使用Html插件从单个js文件条目生成html文件。

我用“ npm install c3安装了c3”

chart.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没有提供有关如何在ES6导入中进行npm安装和使用的说明。

谢谢

javascript d3.js es6-modules c3.js
1个回答
0
投票

固定:

-从'c3'导入*作为c3

+从'c3'导入c3]

© www.soinside.com 2019 - 2024. All rights reserved.