hookehuyr

fix 修复为节点自定义ID后,节点和连接线显示不正常的问题

......@@ -2,7 +2,7 @@
<div class="app" style="height: 100vh">
<vue-flow-editor
ref="editor"
menuWidth="180px"
menuWidth="200px"
modelWidth="300px"
:data="state.data"
:grid="showGrid"
......@@ -1004,6 +1004,11 @@ export default {
}
}
}
// TODO: 测试更新ID, 需要在添加前更新ID,不然会导致添加连接线时ID不一致。
model.id = String(new Date().getTime());
editor.updateModel(model);
state.data.nodes = editor.editorState.graph.save().nodes
}
}
......@@ -1016,9 +1021,6 @@ export default {
function handleAfterAdd(model: myObj, type: string) {
if (type === 'node') {
console.log(`新增节点`)
// TODO: 测试更新ID,窗口变化时连接线会消失,但是只有单独操作一次的时候才会发生,如果多次生成连接线不会发生。
model.id = String(new Date().getTime());
editor.updateModel(model);
state.data.nodes = editor.editorState.graph.save().nodes
}
if (type === 'edge') {
......