首页 > 其他分享 >Vue3中的单击双击事件

Vue3中的单击双击事件

时间:2022-10-12 09:56:32浏览次数:54  
标签:const log 单击 timer value Vue3 双击

<script setup>
  import { ref } from 'vue'
  let timer = ref('')

  const handleClick= () => {
    if(timer.value) {
      clearTimeout(timer.value)
    }
    timer.value = setTimeout(() => {
      console.log('单击事件')
      //你的操作
    }, 300)
  }

  const handleDblClick= () => {
    if(timer.value) {
      clearTimeout(timer.value)
    }
    console.log('双击事件');
//你的操作 } </script> <template> <div @click="handleClick" @dblclick="handleDblClick">示例</div> </template>

  

标签:const,log,单击,timer,value,Vue3,双击
From: https://www.cnblogs.com/reround/p/16783477.html

相关文章