vue3 用ref定义变量接收new Graph初始化值,在使用此变量添加数据,拖动节点会报导致页面卡死 #6097
lhuazai posted onGitHub
Describe the bug / 问题描述
vue3 用ref定义变量接收new Graph初始化值,在使用此变量添加数据,拖动节点会报导致页面卡死 使用正常的变量接收new Graph初始化值没有问题
Reproduction link / 重现链接
No response
Steps to Reproduce the Bug or Issue / 重现步骤
`<template> <div id="graphDom" style="width: 600px;height: 600px;border: 1px solid #ccc"></div> </template>
<script setup lang="ts" name=""> import { Graph } from '@antv/g6' import { onMounted, ref } from 'vue'; let graphObj = ref(); const initGraph = () => { graphObj.value = new Graph({ container: document.getElementById('graphDom'), width:600, height: 600, layout: { type: 'combo-combined', comboPadding: 2, }, plugins:['grid-line'], node: { style: { size: 20, labelText: (d) => d.id, }, palette: { type: 'group', field: (d) => d.combo, }, }, edge: { style: (model) => { const { size, color } = model.data; return { stroke: color || '#99ADD1', lineWidth: size || 1, }; }, }, behaviors: ['drag-element', 'drag-canvas', 'zoom-canvas'], autoFit: 'view', data: { nodes: [], edges: [], combos: [] } }) graphObj.value.render(); } onMounted(()=> { initGraph(); const data = { nodes:[{"id":"0","combo":"a"},{"id":"1","combo":"a"},{"id":"2","combo":"b"}], edges:[{"source":"0","target":"1"},{"source":"0","target":"2"}], combos:[{"id":"a","data":{"label":"Combo A"}},{"id":"b","data":{"label":"Combo B"}}] }; graphObj.value.addData(data); graphObj.value.render(); }) </script>`
G6 Version / G6 版本
🆕 5.x
Operating System / 操作系统
Windows
Browser / 浏览器
Chrome
Additional context / 补充说明