removeComboData导致一系列问题 #5867
hh1412 posted onGitHub
Describe the bug / 问题描述
1.removeComboData后跟着render()会导致报错Node not found forid: combo1 2.当removeCombo后 不跟render的话 画布没有更新 但是combo实际被干掉了 导致还能touch到这个combo 导致报错 Unknown element type of id: combo1
Reproduction link / 重现链接
No response
Steps to Reproduce the Bug or Issue / 重现步骤
<!DOCTYPE html>
<html lang="en">
<head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head>
<body> <button id="btn">取消组合</button> <!-- 准备一个容器 --> <div id="container" style="width: 800px; height: 600px"></div> <!-- 引入 G6 的 JS 文件 --> <script src="https://cdnjs.cloudflare.com/ajax/libs/antv-g6/5.0.1/g6.min.js" integrity="sha512-scKcNGMhnPCMzVTRC3N+BBoV/w5fysdZJ3SDUziOcPNUG6eMs9jN+B7BZzwlxHtgiT750kplRvv/EiNQObQwow==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script> const Graph = window.G6.Graph const graph = new Graph({ container: document.getElementById("container"), plugins: [{ type: 'grid-line', key: 'grid-line', follow: true }], data: { nodes: [ { id: "node-1", combo: 'combo1', style: { x: 50, y: 100 }, }, { id: "node-2", combo: 'combo1', style: { x: 150, y: 100 }, }, { id: "node-3", combo: 'combo1', style: { x: 200, y: 100 }, }, ], combos: [{ id: 'combo1', style: { transform: 'rotate(30deg)' } }], edges: [{ id: "edge-1", source: "node-1", target: "node-2" }], }, combo: { type: 'rect', style: { stroke: '#000', } }, behaviors: [ 'drag-canvas', 'zoom-canvas', 'drag-element', ], x: 0, y: 0, }) graph.render() document.getElementById('btn').addEventListener('click', e => { let comboData = graph.getComboData() console.log(comboData) graph.removeComboData(comboData.map(_ => _.id)) // 跟着render()就会报Error: Node not found for id: combo1 不跟就不会 // graph.render() }) </script>
</body>
</html>
G6 Version / G6 版本
🆕 5.x
Operating System / 操作系统
Windows
Browser / 浏览器
Chrome
Additional context / 补充说明
操作系统win10 浏览器谷歌 版本 125.0.6422.113(正式版本) (64 位) g6版本 5.0.1