大家好,我正在使用 Angular2 CLI 并尝试导入 chart.js 模块,但每次我运行服务器时,我都会收到“找不到模块“chart.js””
import { Component } from '@angular/core';
import Chart from 'chart.js';
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
title = 'Test';
let myChart = new Chart({});
};
最佳答案
看起来您可能错误地声明了图表导入
你有:
import Chart from 'chart.js';
但应该是:
import { Chart } from 'chart.js';
还要检查你是否安装了 chart.js npm 包,如果你没有正确安装它,你可以安装它:
npm install chart.js --save
关于javascript - 找不到模块 'chart.js'。)Angular 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43103746/