[英]Uncaught ReferenceError : require is not defined - Chart.js
in your code, pull the bundle instead. 在你的代码中,改为拉取包。 Eg ~/Plugin/Chart.js/dist/Chart.bundle.js 例如〜/ Plugin / Chart.js / dist / Chart.bundle.js
Use Chart.bundle.min.js bundle found on this page: https://cdnjs.com/libraries/Chart.js 使用此页面上的Chart.bundle.min.js软件包: https ://cdnjs.com/libraries/Chart.js
https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.bundle.min.js https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.bundle.min.js
For the Angular CLI users -> No need to add this script in angular-cli.json file, because angular-cli should pack ng2-charts lib(and other from node_modules) and add it automatically to your index.html. 对于Angular CLI用户 - >无需在angular-cli.json文件中添加此脚本,因为angular-cli应该打包ng2-charts lib(以及其他来自node_modules)并自动将其添加到index.html。
https://github.com/valor-software/ng2-charts/issues/832 https://github.com/valor-software/ng2-charts/issues/832
I had the same problem after installing with Bower. 安装Bower后我遇到了同样的问题。
The solution as proposed in https://github.com/jtblin/angular-chart.js/issues/466 was to get specific versions of chart.js and angular-chart.js (tested with angular 1.4.0) https://github.com/jtblin/angular-chart.js/issues/466中提出的解决方案是获取特定版本的chart.js和angular-chart.js(使用角度1.4.0进行测试)
If you use Bower, try this in your bower.json 如果你使用Bower,请在你的bower.json中试试
"chart.js": "npm:chart.js#2.1.0",
"angular-chart.js": "1.0.1"
and then run: bower install
然后运行: bower install
If npm:chart.js is not working for you, you need to use a resolver. 如果npm:chart.js不适合您,则需要使用解析器。
1- Add to your .bowerrc: 1-添加到.bowerrc:
{
"resolvers": [
"bower-npm-resolver"
]
}
2- Install bower-npm-resolver 2-安装bower-npm-resolver
npm install -g bower-npm-resolver
3- Now run bower install
again 3-现在再次运行bower install
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.