1. 程式人生 > 其它 >vue 點選獲取滑鼠座標(滑鼠位置)

vue 點選獲取滑鼠座標(滑鼠位置)

技術標籤:Vue獲取滑鼠座標

<button @click="getMouseXY($event)">點選獲取滑鼠座標</button>
            getMouseXY(e){
                this.x = e.x //獲取滑鼠的X座標(滑鼠與螢幕左側的距離,單位為px)
                this.y = e.y //獲取滑鼠的Y座標(滑鼠與螢幕頂部的距離,單位為px)
            },