事件修饰符:

  • .stop 阻止冒泡

  • .prevent 阻止默认事件

  • .capture 添加事件侦听器时使用事件捕获模式

  • .self 只当事件在该元素本身(比如不是子元素)触发时触发回调

  • .once 事件只触发一次

<!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="./lib/vue-2.4.0.js"></script>
<style>
.inner {
height: 150px;
background-color: darkcyan;
}

.outer {
padding: 40px;
background-color: red;
}
</style>
</head>

<body>
<div >
</div>
</div> -->

</div>

<script>
// 创建 Vue 实例,得到 ViewModel
var vm = new Vue({
el: '#app',
data: {},
methods: {
div1Handler() {
console.log('这是触发了 inner div 的点击事件')
},
btnHandler() {
console.log('这是触发了 btn 按钮 的点击事件')
},
linkClick() {
console.log('触发了连接的点击事件')
},
div2Handler() {
console.log('这是触发了 outer div 的点击事件')
}
}
});
</script>
</body>

</html>

  vuejs基础-事件修饰符

vuejs基础-事件修饰符

 vuejs基础-事件修饰符

vuejs基础-事件修饰符

vuejs基础-事件修饰符

vuejs基础-事件修饰符

vuejs基础-事件修饰符

 

相关文章:

  • 2022-02-07
  • 2020-06-17
  • 2021-03-31
  • 2021-09-28
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-06
  • 2022-12-23
  • 2022-01-21
  • 2022-12-23
  • 2021-08-02
  • 2021-06-15
  • 2022-01-09
相关资源
相似解决方案