版本
@antv/g6: 4.8.10
踩坑
根据官网文档注册自定义节点时如果绘制dom类型shape,会发现node相关事件全都无法触发,比如node:click等
例如:
G6.registerNode...g6只有svg渲染模式画布可以支持dom类型节点,原理是通过foreignObject标签渲染dom
在事件触发时canvas会对比svg dom拾取的对象和shape对应的标签确定触发哪个节点的事件...@antv/g-base/src/event/event-controller.ts
// 触发事件
_triggerEvent(type, ev) {
const pointInfo..._emitEvent(type, ev, pointInfo, preShape, preShape, null); // 先触发图形的事件
}
this...._emitEvent(type, ev, pointInfo, null, preShape, null); // 再触发离开画布事件
if (type === 'mouseleave'