我正在尝试将mxgraph库集成到webpack / rails项目中。
但是我面临一个问题。
我尝试遵循仓库中的webpack示例: https://github.com/jgraph/mxgraph/blob/master/javascript/examples/webpack/src/anchors.js
但是,当我加载包含容器的页面时,它会引发错误:
Uncaught TypeError: Cannot read property 'prototype' of undefined
对于此对应的行:
mxGraph.prototype.getAllConnectionConstraints = function(terminal, source)
我认为此声明无法正常工作:
var mxgraph = require("../../../node_modules/mxgraph/javascript/dist/build"),
mxGraph = mxgraph.mxGraph,
mxShape = mxgraph.mxShape,
mxConnectionConstraint = mxgraph.mxConnectionConstraint,
mxPoint = mxgraph.mxPoint,
mxPolyline = mxgraph.mxPolyline,
mxEvent = mxgraph.mxEvent,
mxRubberband = mxgraph.mxRubberband,
mxCellState = mxgraph.mxCellState;
总之,将mxgraph包含到webpack / rails项目中的正确方法是什么?
提前谢谢!