1. <html>
    2. <body>
    3. <div id="app">
    4. </br>
    5. <!-- 正常写法 -->
    6. <p v-on:mousemove="myMouseMove"> 鼠标移动 </p>
    7. </br>
    8. mouseX:{{myMouseX}} </br>
    9. mouseX:{{myMouseY}} </br>
    10. </br>
    11. <!-- 缩写写法 -->
    12. <p @mousemove="myMouseStop"> 鼠标停止1 </p>
    13. </br>
    14. <!-- 事件修饰符 -->
    15. <p @mousemove.stop> 鼠标停止2 </p>
    16. </div>
    17. </body>
    18. <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    19. <script>
    20. new Vue({
    21. //指定作用于那一个div
    22. el:'#app',
    23. //属性
    24. data:{
    25. myMouseX:0,
    26. myMouseY:0,
    27. },
    28. methods:{
    29. myMouseMove:function(event){
    30. this.myMouseX=event.clientX;
    31. this.myMouseY=event.clientY;
    32. },
    33. myMouseStop:function(event){
    34. event.stopPropagation();
    35. }
    36. }
    37. });
    38. </script>
    39. </html>