vue3 的 防抖

function init (val) {
      banks({ bankName: val }).then((res) => {
        data.bankList = res.resultData
      })
    }
    function getKeyWordLish (val) {
      return setTimeout(() => {
        init(val)
      }, 500)
    }
    watchEffect((onInvalidate) => {
      const timer = getKeyWordLish(value.value)// 再重新生成定时器
      onInvalidate(() => {
        clearTimeout(timer)
      })
    })
posted @ 2021-08-05 11:09  未几  阅读(637)  评论(0编辑  收藏  举报