g6版本:2.2.5
1,我先import导入g6.
import G6 from '@antv/g6';
2,在导入Plugins
import Plugins from '@antv/g6/plugins/';
3,在实例化
const dagre = new Plugins'layout-dagre';
const graph = new G6.Graph({
container: 'mountNode',
fitView: 'cc',
height: window.innerHeight, // 画布高
plugins: [dagre],
defaultIntersectBox: 'rect' // 使用矩形包围盒
});
但是它报错
ERROR TypeError: _antv_g6_plugins___WEBPACK_IMPORTED_MODULE_2___default.a.layout-dagre is not a constructor
我也遇到这样的问题,然后使用以下的方法解决了
import '@antv/g6/build/plugins'
const graph = new G6.Graph({
container: 'mountNode',
plugins: [new G6.Plugins'layout.dagre'],
fitView: 'cc',
height: 500, // 画布高
defaultIntersectBox: 'rect' // 使用矩形包围盒
})
Most helpful comment
我也遇到这样的问题,然后使用以下的方法解决了
import '@antv/g6/build/plugins'
const graph = new G6.Graph({
container: 'mountNode',
plugins: [new G6.Plugins'layout.dagre'],
fitView: 'cc',
height: 500, // 画布高
defaultIntersectBox: 'rect' // 使用矩形包围盒
})