js - 获得鼠标当前的位置

访问量: 57

https://stackoverflow.com/questions/45553162/how-to-get-mouse-coordinates-in-vuejs
methods: {
    someMethod(event) {
        // clientX/Y gives the coordinates relative to the viewport in CSS pixels.
        console.log(event.clientX); // x coordinate
        console.log(event.clientY); // y coordinate

        // pageX/Y gives the coordinates relative to the  element in CSS pixels.
        console.log(event.pageX); 
        console.log(event.pagey); 

        // screenX/Y gives the coordinates relative to the screen in device pixels.
        console.log(event.screenX);
        console.log(event.screenY);
    }
}

订阅/RSS Feed

Subscribe

分类/category