使用角2.4.0,TSC2.3.1,我尝试使用Dagre与JointJS/graphlib一起使用SystemJS作为加载器在SystemJS中绘制图形。
http://www.daviddurman.com/automatic-graph-layout-with-jointjs-and-dagre.html
我不知道如何按照JointJS var dagre = require('dagre');的要求在浏览器中获取“dagre”对象
我的Angular2组件包括import * as dagre from 'dagre';
我的SystemJS配置:
(function () {
System.config({
map: {
'dagre': '/static/libs/dagre/dagre.js'
}
});
})();当JointJS试图调用dagre.layout:Cannot read property 'layout' of undefined时,无法加载dagre会导致未定义的错误
// Executes the layout.
dagre.layout(glGraph, { debugTiming: !!opt.debugTiming });也许这是库本身没有导出的问题,还是我必须在SystemJS配置中指定一种格式?
发布于 2017-05-03 22:53:28
所以我不知道到底是什么解决了这个问题,但我做了三件事:
1) npm install -D @types/dagre
2) import * as dagre from dagre; in my component.ts
3)添加的格式:全局到SystemJS配置
(function () {
System.config({
map: {
'lodash': '/static/libs/lodash/index.js',
'dagre': '/static/libs/dagre/dagre.js',
'graphlib': '/static/libs/graphlib/grpahlib.umd.js',
},
meta: {
'dagre': {
format: 'global',
deps: ['lodash'],
},
'graphlib': {
format: 'global',
deps: ['lodash'],
}
}
});
})();https://stackoverflow.com/questions/43744940
复制相似问题