在ionic3 app的任何服务中
rabbit:connection-factory id="connectionFactory" addresses="host1, host2, host3" username="username" password="password"
输出错误是这个
import * as jsnx from 'jsnetworkx';
我试图以这种方式声明
Uncaught (in promise): Error: Cannot find module "lodash/lang/isPlainObject" Error: Cannot find module "lodash/lang/isPlainObject" at webpackMissingModule
,错误就是这个
import jsnx = require('jsnetworkx');
安装了两个包
Uncaught (in promise): ReferenceError: jsnx is not defined ReferenceError: jsnx is not defined at
如果有人知道如何在角度4 o ion中工作吗?
节点工作正常的库。
答案 0 :(得分:2)
我能够通过安装d3 v3(jsnetworkx的依赖关系)和jsnetworkx来实现这个目的
npm install --save d3@^3.0.0
npm install --save jsnetworkx
然后在angular-cli.json
中加载d3脚本// angular-cli.json
scripts: [
"../node_modules/d3/d3.min.js"
]
然后将jsnetworkx导入组件
// component.ts
import * as jsnx from 'jsnetworkx';
现在您可以在该组件中使用它
// component.ts
ngOnInit(){
// basic jsnetworkx example
let G = new jsnx.Graph();
G.addWeightedEdgesFrom([[2,3,10]]);
G.addStar([3,4,5,6], {weight: 5});
G.addStar([2,1,0,-1], {weight: 3});
jsnx.draw(G, {
element: '#canvas',
weighted: true,
edgeStyle: {
'stroke-width': 10
}
});
}
// component.html
<div id="canvas"></div>