zoukankan      html  css  js  c++  java
  • vue中的防抖与节流,minxin

    参考文档:

    https://www.jb51.net/article/161713.htm
     
    或者
     
    // 防抖
    const debounce = (func, wait, immediate) => {
                let timeOut;
                return function () {
                    const context = this;
                    const args = arguments;
                    if (timeOut) {
                        clearTimeout(timeOut);
                    }
                    if (immediate) {
                        let callNow = !timeOut;
                        timeOut = setTimeout(() => {
                            timeOut = null;
                        }, wait || 500)
                        if (callNow) {
                            func.apply(context, args);
                        }
                    } else {
                        timeOut = setTimeout(() => {
                            func.apply(context, args);
                        }, wait || 500);
                    }
    
                }
            }
    // 组件中调用
    <el-input type='text' @input="test($event)">
    
    // 引入防抖
    import {Debounce} from './utils';
    
    
    export default {
    
        methods:{
    
            test(e){
    
                Debounce(()=>{
                   console.log(e);
                },1000)
            }
        
    
        }
    }            

     Minxin参考地址:https://blog.csdn.net/qq_38128179/article/details/107817436

  • 相关阅读:
    Sword 17
    Sword 16
    Sword 15
    Sword 14-II
    Sword 14-I
    Sword 13
    Sword 11
    Sword 10-II
    Sword 10
    【python+selenium】三种等待方式
  • 原文地址:https://www.cnblogs.com/huangmin1992/p/15547680.html
Copyright © 2011-2022 走看看