VUE event binding modifier

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
</head>
<style>
#box{width: 200px;height: 200px; background: red;}
 
</style>

<body>
<div id="app">
<div id="box" @click='boxfunc'>
<Button id = "btn" @ click.stop = 'btnfunc'> prevent bubbling </ button>
<a href="http://www.baidu.com" @click.stop.prevent> to prevent the default event and bubbling </a>
</div>
<div id="box" @click.capture='boxfunc'>
<Button id = "btn" @ click.stop = 'btnfunc'> prevent bubbling </ button>
<a href="http://www.baidu.com" @click.prevent> prevent the default event </a>
</div>
<div id="box" @click.self='boxfunc'>
<a href="http://www.baidu.com" @click.prevent.once> performed only once, the second jump </a>
</div>
<P> event modifier, stop stop bubbling, capture capture mechanism, prevent the default behavior to stop, once triggered only once, self triggered only own events </ p>
</div>

 
<script>
was vm = new Vue ({
the '# app'
data:{
 
},
methods: {
boxfunc(){
alert ( 'This is a box of events')
},
btnfunc () {
alert ( 'This is an event btn')
},
 
}
 
 
});
</script>
</body>

</html>

Guess you like

Origin www.cnblogs.com/xiannv/p/10966094.html