zoukankan      html  css  js  c++  java
  • input vue ts 防抖处理

     
    <el-input  @input="debounce()" ></el-input>
     
     
    // 防抖处理
    private timer: any = ''
    private debounce(data?: any) {
        let that = this
        if (this.timer) {
          clearTimeout(this.timer)
        }
        this.timer = setTimeout(function() {
         //写你需要防抖处理的事件
          // console.log('输入')
          that.timer = undefined
        }, 1000)
      }
     
     
     
     
    //节流
     
    <div  @click="throttle()" >点击点击</div>
     
     
     private timer: any = ''
     private lastTime: any = ''
     private throttle() {
        let that = this
        let now = +new Date()
        if (this.lastTime && this.lastTime - now < 2000) {
          clearTimeout(this.timer)
        }
        this.timer = setTimeout(function() {
          console.log('点击')
          that.lastTime = +new Date()
        }, 200)
      }
     
  • 相关阅读:
    HDU 1495 广度优先搜索
    oj 1792:迷宫 广搜和深搜
    oj 1756:八皇后 搜索
    OJ1700 八皇后问题 基本搜索算法
    PAT A1020
    PAT A1103
    PAT A1046 Shortest Distance
    PAT A1059
    PAT B1013
    二分查找
  • 原文地址:https://www.cnblogs.com/lucy1111/p/14341433.html
Copyright © 2011-2022 走看看