我想在我的Angular 项目中使用Chart.js. 在以前的Angular2版本中,我已经通过使用‘chart.loader.ts’很好地做到了这一点,它具有:
export const { Chart } = require('chart.js');
然后在组件代码中
import { Chart } from './chart.loader';
但是在升级到cli 1.0.0和Angular 4之后,我收到错误:"找不到名称‘REQUIRED’".
要重现错误,请执行以下操作:
ng new newapp
cd newapp
npm install chart.js --save
echo "export const { Chart } = require('chart.js');" >> src/app/chart.loader.ts
ng serve
在我的电脑里.是的,我有
"typeRoots": [
"node_modules/@types"
],
在'node_modules/@types/node/index'中.d、 有:
declare var require: NodeRequire;
所以我很困惑.
顺便说一句,我经常遇到这样的警告:
[tslint] The selector of the component "OverviewComponent" should have prefix "app"(component-selector)
虽然我已经在我的字典里设置了前缀":".好的.json'.可能是因为从"Angular "改变了.json"to".好的.原因是什么?