0
A
回答
2
Vue通过event
作为方法中的第一个参数。如果是参数,则改为:someMethod(param1,param2,event)
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 <html> 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);
}
}
2
你一样会和在任何事件处理
new Vue({
el: '#element',
methods: {
someMethod: function (event) {
var x = event.pageX;
var y = event.pageY;
}
}
})
还有clientX
和screenX
,他们返回基于视窗,在屏幕上或呈现的内容有所不同的结果。
相关问题
- 1. 如何获取鼠标坐标和.push()?
- 2. WPF在viewmodel中获取鼠标坐标
- 3. 如何在C#中获取当前的鼠标光标坐标?
- 4. 在C#中单击鼠标获取鼠标坐标
- 5. 如何在QGraphicsView中获取鼠标释放坐标
- 6. 获取鼠标屏幕坐标点击
- 7. 使用jQuery获取鼠标坐标
- 8. jfreechart的获取鼠标坐标
- 9. 获取鼠标坐标(哈斯克尔)
- 10. 如何根据鼠标点击获取3D中点的坐标?
- 11. 如何获取WPF中的当前鼠标屏幕坐标?
- 12. 获取鼠标坐标不断,而鼠标移动onmousedown事件
- 13. 鼠标坐标
- 14. 如何显示图片并获取鼠标点击坐标
- 15. Flex Datagrid - 如何获取鼠标x/y坐标的项目?
- 16. 如何从鼠标位置获取已翻译的坐标
- 17. 如何获取鼠标点击时的坐标
- 18. 在JS中,如何获得DIV内的鼠标坐标?
- 19. OpenLayers 3在选定的交互中获取鼠标坐标
- 20. Swift - 在UIElement中获取鼠标点击坐标
- 21. 获取鼠标在Firefox中的坐标18,IE 9,Chrome 24
- 22. 如何获取vtkboxwidget坐标
- 23. 如何获取UIImageView坐标?
- 24. VB.NET - 鼠标坐标
- 25. 如何在flex papervision3d上获得鼠标z坐标?
- 26. 从框架中获取鼠标单击的坐标
- 27. Windows鼠标坐标VS OpenGL鼠标坐标
- 28. OpenGL在C++中鼠标点击时获得光标坐标
- 29. Java Slick2d - 如何将鼠标坐标转换为世界坐标
- 30. 在javascript中的鼠标坐标?