May*_*urb 2 raphael webpack package.json angular
我有一个Angular项目,我正在使用morris.js.我的package.json像这样引用了morris和raphael:
dependencies{
....
"raphael": "^2.2.7",
"morris.js": "0.5.0",
....
}
Run Code Online (Sandbox Code Playgroud)
我还检查了node_module文件夹,两个依赖项都存在.在mycomponent.ts中,我这样做:
import 'morris.js';
export class mycomponent implements OnInit {
areaChart: morris.GridChart;
.....
this.areaChart = Morris.Area({
.....)}
}
Run Code Online (Sandbox Code Playgroud)
我收到错误"ERROR ReferenceError:Raphael未定义"
它正在被morris.js解雇 this.raphael = new Raphael(this.el[0]);
我应该如何在莫里斯中包括拉斐尔才能使其发挥作用?
小智 5
我有同样的问题,我通过添加:
new webpack.ProvidePlugin({ Raphael: 'raphael' })
Run Code Online (Sandbox Code Playgroud)
到我的webpack.config.js插件部分,使Raphael全球可用.我还补充说:
new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', jquery: 'jquery' })
Run Code Online (Sandbox Code Playgroud)
早些时候,jQuery也可以在全球范围内运行.
| 归档时间: |
|
| 查看次数: |
908 次 |
| 最近记录: |