环境:vue、mint-ui

功能:一个输入框,按下按键之后就执行某个功能。

截图:一个输入框

mint-ui 输入框按下按键执行查询

输入框html:

<mt-search v-model="query" cancel-text="" placeholder="提取码">   // mt-search 
基本函数:
debounce (func, delay) {
      let timer
      return function (...args) {
        if (timer) {
          clearTimeout(timer)
        }
        timer = setTimeout(() => {
          func.apply(this, args)
        }, delay)
      }
    }

查询函数:

getData () {
  console.log('执行查询。。。。。。')
},

主要函数:

1 created() {
2     this.$watch('query', this.debounce(newQuery => {
3       if (newQuery) {
4         setTimeout(() => {
5           this.getData()
6         }, 20)
7       }
8     }, 200))
9   },

 

 
 

相关文章:

  • 2021-08-20
  • 2021-04-18
  • 2021-10-20
  • 2022-01-20
  • 2021-07-17
  • 2021-08-27
  • 2021-10-14
猜你喜欢
  • 2021-12-14
  • 2021-09-06
  • 2022-12-23
  • 2022-12-23
  • 2021-09-20
  • 2021-11-09
  • 2021-12-03
相关资源
相似解决方案