情况:从别的页面跳转过来,本来应该绘图,结果没有绘制线条
解决办法:创建实例
原代码:
print (point1, point2) {
jsPlumb.ready(function () {
jsPlumb.connect({
source: point1,
target: point2,
endpoint: 'Blank',
paintStyle: { stroke: '#999', strokeWidth: 1 },
connector: ['Flowchart'],
anchor: ['Bottom', 'Top'],
overlays: [
['Arrow', { width: 12, length: 12, location: 0.9 }],
[
'Label',
{
// label: '我是文字啊\r\n  ',
id: 'myLabel',
location: 0.5,
labelStyle: { color: '#47df33' }
}
]
],
maxConnections: -1
});
});
}
修改后:
print (point1, point2) {
let plumbIns = jsPlumb.getInstance(); / /这里是重点!!!
plumbIns.ready(function () {
plumbIns.connect({
source: point1,
target: point2,
endpoint: 'Blank',
paintStyle: { stroke: '#999', strokeWidth: 1 },
connector: ['Flowchart'],
anchor: ['Bottom', 'Top'],
overlays: [
['Arrow', { width: 12, length: 12, location: 0.9 }],
[
'Label',
{
// label: '我是文字啊\r\n  ',
id: 'myLabel',
location: 0.5,
labelStyle: { color: '#47df33' }
}
]
],
maxConnections: -1
});
}
找了好长的时间!!!