【发布时间】:2018-02-17 02:45:52
【问题描述】:
我有一个 Angular 项目,我正在使用 morris.js。我的 package.json 引用了 morris 和 raphael,如下所示:
dependencies{
....
"raphael": "^2.2.7",
"morris.js": "0.5.0",
....
}
我还检查了 node_module 文件夹,两个依赖项都存在。在 mycomponent.ts 中,我正在这样做:
import 'morris.js';
export class mycomponent implements OnInit {
areaChart: morris.GridChart;
.....
this.areaChart = Morris.Area({
.....)}
}
我收到“ERROR ReferenceError: Raphael is not defined”的错误
当它在做 this.raphael = new Raphael(this.el[0]); 时,它被 morris.js 解雇了
我应该如何在 Morris 中加入 Raphael 以使其发挥作用?
【问题讨论】:
-
但是你的 raphael.js 和 morris.js 是在 index.html 中加载的吗???即如果它的 angular cli 项目比你包含在你的 angular-cli.json 中?
-
我有 index.html,但它是一个带有 webpack 的 Angular 4 项目。所以他们不会在 index.html 中包含 js 文件。我尝试在 mycomponent .ts 中添加“import raphael”,但没有帮助。
-
在你的 index.html 中添加 raphael.js 和 morris.js...!
-
这不是正确的做法..
-
我有 webpack.dev.js 和 webpack.common.js..它们都太大了,请告诉我如何将它们发送给您?你也确定,它们是外部js ..我在我的component.ts中导入了其他js,如下所示:import 'morris.js';导入'jquery-knob';导入“引导日期选择器”;导入'jqueryui';导入“日期范围选择器”;导入'jquery-slimscroll';导入“拉斐尔”;导入'admin-lte';并且所有这些都在工作..只有 raphael 不工作...不同之处在于 rappahel 是从 morris.js 内部引用的,这是 node_module 中的另一个库
标签: angular webpack raphael package.json