获取鼠标位置

1  function getMousePosition(event) {
2             const { clientX, clientY } = event;
3             const { top, left } = canvas.getBoundingClientRect();
4             const x = clientX - left;
5             const y = clientY - top;
6             return { x, y };
7         }
View Code
原文地址:https://www.cnblogs.com/LifeFruit/p/13805562.html