vue v-on .stop修饰符

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
  </head>
  <body>
    <div id="app" @click="divClick">
      <p>{{ message }}</p>
      <button type="button" @click="btnClick">btnClick</button>
    </div>

    <script>
      const app = new Vue({
        el: '#app',
        data: {
          message: 'Hello Vue.js!',
        },
        methods: {
          btnClick(event) {
            console.log('btnClick ' + event);
          },
          divClick(event) {
            console.log('divClick ' + event);
          }
        },
      })
    </script>
  </body>
</html>

.stop修饰
<button type="button" @click.stop="btnClick">btnClick</button>

posted @ 2021-07-01 17:01  thomas_blog  阅读(192)  评论(0编辑  收藏  举报