我尝试将 angular-cli 与 D3 一起使用。后
typings install d3 --save
npm install d3
我在 node_modules
并在typings
文件夹中
角-cli-build.js
module.exports = function(defaults) {
var app = new Angular2App(defaults, {
vendorNpmFiles: ['d3/d3.js']
});
return app.toTree();
};
索引.html
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
},
d3: {
'd3': 'vendor/d3/d3.js'
}
});
在bar-chart
指令中我尝试导入 d3
import {Directive} from 'angular2/core';
import d3 from 'd3';
@Directive({
selector: 'bar-graph',
providers: [],
host: {},
})
export class BarGraph {
constructor() {
console.log(d3);
}
}
但是该应用程序永远不会加载,并console.log
说它试图获取 localhost:4200/d3。