简体   繁体   中英

When I tap the screen, the function is called two times

When I tap the element, the callback function is called two times.

I did try with a click event and there are no problems

    <template>
    <div>
      <div v-on:click="tap()">Click</div>
      <a v-hammer:tap="tap">Tap</a>
    </div>
    </template>

    <script>
    export default{
      name: 'say',
      beforeUpdate(){
        console.log('beforeUpdate')
      },
      updated(){
        console.log('updated')
      },
      methods: {
        tap(){
          console.log('Say',Date())
        }
      }
    }
    </script>

I expect the callback function is called once

您应该使用@click.native.prevent来避免传播,就像文档解释的那样: https ://v2.vuejs.org/v2/guide/events.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM