SoFunction
Updated on 2025-04-03

vue uses the once modifier so that the event can only trigger the problem once

Once modifier, so that the event can only be triggered once

Multiple modifiers can be used synchronously

<!--definitionvueOperation object-->
<div >
    <!-- useselfModifier Events will be executed only when the tag itself is clicked -->
    <!-- useonceModifier Make the event only triggered once  -->
    <!-- 多个Modifier可以同时use   -->
    <div class="inner" @="divClick">
        <input type="button" value="Click" @click="butClick">
    </div>
</div>
<!--Import-->
<script src="./"></script>
<script>
    //Create a vue instance    var vm = new Vue({
        el:"#app", //Specify the DOM element controlled by the instance      data:{ //Storage page data        },
        methods:{ //Define all methods available for instance here            divClick(){
                ('div click event')
            },
            butClick(){
                ('button click event')
            }
        }
    })
</script>

vue event modifier (once:prev:stop)

Attached with html files, js files and css files under the same folder

The comments are very detailed

Code

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>vue</title>
	<link rel="stylesheet" href="" rel="external nofollow" >
	<script src="/npm/vue"></script>
</head>
<body>
	<!--vue-appIt's the root container-->
	<div >
	<h1>Event</h1>
	<button @="add(1)">Click to increase one year old</button>
	<button v-on:click="subtract(1)">Click to reduce one year</button>
	<button @dblclick="add(10)">Double click to increase ten years old</button>
	<button v-on:dblclick="subtract(10)">Double click to reduce ten years old</button>
	<p>My age is {{age}}</p>
	
	<div  v-on:mousemove="updateXY">
	{{x}},{{y}} - 
	<span v-on:mousemove="stopMoving">Stop Moving</span>
	<br>
	<span v-on:="">Stop Moving</span>
	</div>
	<a v-on:click="alert()" href="/qq_40647912" rel="external nofollow"  rel="external nofollow" >baidu</a>
	<br>
	<a v-on:="alert()" href="/qq_40647912" rel="external nofollow"  rel="external nofollow" >baidu</a>
	</div>
	</div>
	<script src=""></script>
	
</body>
</html>

Code

//Instantiate VUE objectnew Vue({
	el:"#vue-app",
	// Only in vue-app container	data:{
		age:30,
		x:0,
		y:0
		},
	methods:{
		add:function(inc){
			 += inc;
		},
		subtract:function(dec){
			 -= dec;
		},
		updateXY:function(event){
			 = ;
			 = ;
		},
		stopMoving:function(event){
			();
		},
		alert:function(){
			alert("Hellow world !");
		}
	}
});

Code

#canvas{
	width: 600px;
	padding: 200px 20px;
	text-align: center;
	border: 1px solid #333;
}

The above is personal experience. I hope you can give you a reference and I hope you can support me more.