mirari / v-viewer

Image viewer component for vue, supports rotation, scale, zoom and so on, based on viewer.js
https://mirari.cc/v-viewer/
MIT License
2.47k stars 294 forks source link

监听mousedown事件,只有鼠标滚轮和右键能触发,鼠标左键不能触发 #336

Closed yzw625 closed 1 month ago

yzw625 commented 1 month ago

使用背景:在modal模式下覆盖一层canvas元素,通过给canvas元素添加鼠标事件,如下代码: const canvas = document.createElement('canvas'); const rect = image.getBoundingClientRect(); canvas.width = rect.width; canvas.height = rect.height; canvas.style.position = 'absolute'; canvas.style.top =${rect.top}px; canvas.style.left =${rect.left}px`; canvas.style.zIndex = '9999'; canvas.style.pointerEvents = 'auto'; canvas.style.border = '1px solid red';

// 将 Canvas 添加到 canvas 层上 image.parentElement.appendChild(canvas);`

但是给canvas元素添加mousedown监听事件,只有鼠标滚轮和右键能触发,左边不能触发,请问会是什么原因呢?