antvis/G6

ContextMenu 在使用getContent构建菜单内容时,内容为追加,而非将菜单清空后构建。 #5965

Nciae-Zyh posted onGitHub

Describe the bug / 问题描述

ContextMenu 在使用getContent构建菜单内容时,内容为追加,而非将菜单清空后构建。通过研究源码发现贵方在[@antv/g6/src/plugins/contextmenu/index.ts,128-132]代码如下 if (content instanceof HTMLElement) { this.$element.appendChild(content); } else { this.$element.innerHTML = content; } 显示为若返回HTMLElement类型,则是追加子元素而非重新渲染。是否是我使用的不规范。或者是说有其他方法可以我需要的自定义菜单。

No response

Steps to Reproduce the Bug or Issue / 重现步骤

将getContent设置为handleContextMenu,渲染出多个不同的Node,通过在Node节点间点击,则可以实现重复渲染。

const handleContextMenu = async (event: IElementEvent) => { // 创建一个临时的 div 元素 const tempDiv = document.createElement('div');

// 创建一个 Vue 应用实例并挂载到临时的 div 元素上 const app = createApp({ render() { return h('div', '123'); } });

app.mount(tempDiv); // 返回包含已渲染组件的 div return tempDiv; }, 1. image 2. image 3. image

G6 Version / G6 版本

🆕 5.x

Operating System / 操作系统

Linux

Browser / 浏览器

Chrome

Additional context / 补充说明

No response


我看了下,确实是实现上有问题,这边会尽快修复

posted by Aarebecca 10 months ago

Fund this Issue

$0.00
Funded

Pull requests