From 06c015f707971d146dca7a72f9dfe74fc575b5ce Mon Sep 17 00:00:00 2001 From: guoapeng Date: Wed, 16 Jul 2025 11:01:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=80=89=E5=8C=BA=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=92=8C=E7=82=AB=E9=85=B7=E7=9A=84=E6=93=8D=E4=BD=9C=E4=BA=92?= =?UTF-8?q?=E4=B8=8D=E5=BD=B1=E5=93=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/spray/trayGraph/index.vue | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/spray/trayGraph/index.vue b/src/components/spray/trayGraph/index.vue index a95d0b7..fa1096a 100644 --- a/src/components/spray/trayGraph/index.vue +++ b/src/components/spray/trayGraph/index.vue @@ -76,7 +76,8 @@ const addSelect = () => { }) // 在onMounted中rect创建后添加拖拽监听 - rect.value.on('dragmove', () => { + rect.value.on('dragmove', (event: any) => { + event.cancelBubble = true // 阻止事件冒泡 const pos = rect.value.position() const width = newWidth const height = newHeight @@ -91,13 +92,14 @@ const addSelect = () => { // 修正位置 rect.value.position({ x: newX, y: newY }) + layer.value.batchDraw() // 刷新层以反映更新后的位置 }) tr.value = new Konva.Transformer({ rotationEnabled: false, rotateEnabled: false, // 禁用旋转手势 - rotationSnaps: [], // 移除旋转刻度 - anchorSize: 20, + // rotationSnaps: [], // 移除旋转刻度 + anchorSize: 25, // enabledAnchors: ['top-center', 'bottom-center', 'middle-left', 'middle-right'], // 关键修改 enabledAnchors: props.editSelect ? ['top-center', 'bottom-center', 'middle-left', 'middle-right'] : [], boundBoxFunc(oldBoundBox, newBoundBox) { @@ -121,6 +123,14 @@ const addSelect = () => { return newBoundBox }, }) + // 监听 Transformer 的事件以阻止冒泡 + tr.value.on('dragmove', (event: any) => { + event.cancelBubble = true // 阻止事件冒泡 + }) + + tr.value.on('dragend', (event: any) => { + event.cancelBubble = true // 阻止事件冒泡 + }) layer.value.add(rect.value) layer.value.add(tr.value)