Vue3 implements el-button long press release function

<el-button type="info"  @mousedown.native="gmousedown" @mouseup="gmouseup">测试</el-button>

<script>
    export default{
    setup(){
      var myTimeDisplay
      //长按事件(起始)
      function gmousedown() {
        myTimeDisplay = setInterval(() => {
            console.log(123)
        }, 50);
      }
      function gmouseup() {
        clearInterval(myTimeDisplay);
      }
      return{
        gmousedown,
        gmouseup,

      }
    }
  }
</script>

The actual test is useful, if you have any questions, welcome to comment, exchange and learn from each other, hope to like and collect more

Supongo que te gusta

Origin blog.csdn.net/qq_42264030/article/details/127845961
Recomendado
Clasificación