宝哥软件园

通过Vue监控事件依次增加点击次数的方法

编辑:宝哥软件园 来源:互联网 时间:2021-08-29

1.实现计数器功能。每次点击按钮,计数值都会增加一到两个。当鼠标在坐标线中移动时,当前坐标将被更新,事件传播将通过自定义函数或stop属性被禁止。

效果如下:

Vue计数点击依次增加

代码如下:

!doctype html townleta charset=' utf-8 ' title counter from increment function/title script src=' http 3360 vue . js '/script/head body div id=' app ' button v-: click=' increment ' click to add one/button!-自定义步长-按钮v-: click=' increment 2(2,$ event)' click plus two/button p { { count } }/p!-实现鼠标在这一行移动时位置坐标的显示-p v-: mouse move=' updatecordinals ' cordinals 3360({ { x } }/{ { y } })-!-以下两种方法达到了相同的效果-span v-: mouse move=' dummy ' stop update/span!-您不能在stop here后面添加括号-span v-: mouse move。停止停止更新!/span /p /div脚本new Vue({ el:'#app ',data:{ count:0,x:0,y:0 },methods : { incremente : function(){ this . count;},递增e2:function (step,event){ this . count=step;},updatecordinats : function(event){ this . x=event . client x;this . y=event . clienty;},dummy : function(event){ event . stopperpagation();} } } })/script/body/html/html注意:关键词、标签、括号等。不能用中文,否则会出错。

以上依次增加Vue监控事件的计数和点击的方法都是边肖分享的内容。希望能给大家一个参考,多支持我们。

更多资讯
游戏推荐
更多+