vue2.0獲取鼠標位置的方法
更新時間:2018年09月13日 15:22:17 作者:Hi毛哥哥
今天小編就為大家分享一篇vue2.0獲取鼠標位置的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
如下所示:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script type="text/javascript" src="js/vue.js" ></script> <style> #canvas{ width: 500px; height: 500px; text-align: center; line-height: 500px; border: 1px solid #E5E5E5; margin: 0 auto; margin-top: 100px; } </style> </head> <body> <div id="app"> <div id='canvas' @mousemove='updateXY'> {{x}} {{y}} </div> </div> <script> new Vue({ el:'#app', data:{ x:0, y:0 }, methods:{ updateXY:function(event){ this.x=event.offsetX; this.y=event.offsetY } } }) </script> </body> </html>
以上這篇vue2.0獲取鼠標位置的方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
您可能感興趣的文章:
相關文章
vue中for循環(huán)更改數(shù)據(jù)的實例代碼(數(shù)據(jù)變化但頁面數(shù)據(jù)未變)
這篇文章主要介紹了vue中for循環(huán)更改數(shù)據(jù)的實例代碼(數(shù)據(jù)變化但頁面數(shù)據(jù)未變)的相關資料,需要的朋友可以參考下2017-09-09VueX學習之modules和namespacedVueX詳細教程
這篇文章主要為大家介紹了VueX學習之modules和namespacedVueX詳細教程,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-06-06vue使用neovis操作neo4j圖形數(shù)據(jù)庫及優(yōu)缺點
這篇文章主要介紹了vue使用neovis操作neo4j圖形數(shù)據(jù)庫,本文給大家介紹了與常規(guī)做法的優(yōu)缺點對比及使用技巧,對vue?neo4j圖形數(shù)據(jù)庫相關知識感興趣的朋友一起看看吧2022-02-02