美文网首页
vue中capture和self的区别

vue中capture和self的区别

作者: pengtoxen | 来源:发表于2019-04-12 10:17 被阅读0次

.capture先执行父级的函数,再执行子级的触发函数

<div v-on:click.capture='alert("1")' style="width: 100%;height:45px;">
  <div v-on:click="alert('2')" style='width: 80%;margin-left: 10%;'>
    123
  </div>
</div>

此时点击子级的div时,会先执行alert(‘1’),再执行alert(‘2’)
self是只执行子级本身的函数

<div v-on:click.self='alert("1")' style="width: 100%;height: 45px;">
  <div v-on:click="alert('2')" style='width: 80%;margin-left: 10%;'>
    123
  </div>
</div>

此时点击子级的div会执行alert(‘2’),不会执行alert(‘1’)

相关文章

  • vue中capture和self的区别

    .capture先执行父级的函数,再执行子级的触发函数 此时点击子级的div时,会先执行alert(‘1’),再执...

  • vue

    vue的事件修饰符:.stop:阻止冒泡.prevent:阻止默认行为.capture 捕获.self ...

  • vue

    vue的事件修饰符: .stop:阻止冒泡 .prevent:阻止默认行为 .capture .self .onc...

  • vue

    vue的事件修饰符:.stop:阻止冒泡.prevent:阻止默认行为.capture.self CommonJS...

  • vue

    vue的事件修饰符:.stop:阻止冒泡.prevent:阻止默认行为.capture.self CommonJS...

  • vue

    vue的事件修饰符:.stop:阻止冒泡.prevent:阻止默认行为.capture.self CommonJS...

  • VUE注意点

    Vue.js 为 v-on 提供了事件修饰符 .stop .prevent .capture .self .onc...

  • vue事件、指令、钩子

    vue的事件修饰符:.stop:阻止冒泡.prevent:阻止默认行为.capture.self.once:只触发...

  • vue事件、指令、钩子

    vue的事件修饰符:.stop:阻止冒泡.prevent:阻止默认行为.capture.self.once:只触发...

  • Swift中Self和self的区别

    当编写protocol和针对protocol进行扩展时,Self(大写S)和self(小写S)之间存在差异。当与大...

网友评论

      本文标题:vue中capture和self的区别

      本文链接:https://www.haomeiwen.com/subject/aguqwqtx.html