云迈博客

您现在的位置是:首页 > 灌水专栏 > 正文

灌水专栏

js input搜索防抖

zero2022-03-30灌水专栏260
jsinput防抖,防止input多次输入调用多次newVue({el:'#app',data:function(){return{
js input防抖,防止input多次输入调用多次
<el-input class="code" v-model="code" ref="codeInput" @input="codeInput" @blur="codeBlur"></el-input>
new Vue({
     el: '#app',
     data: function() {
         return {
         }
     },
     created() {
     },
     methods: {
         codeInput(val) {
             // 等待扫码结果输入输入框后搜索用户
             this.debounce(this.getUser, 500);
         },
         getUser() {

         },
         debounce (func, wait) {
             if (this.timeout) clearTimeout(this.timeout)
             this.timeout = setTimeout(() => {
                 func()
             }, wait)
         },
     }
 });

发表评论

评论列表

  • 这篇文章还没有收到评论,赶紧来抢沙发吧~