1.在utils文件夹下新建common.js文件
export function debounce (fn, delay) {
var timer = null
var delay1 = delay || 200
return function () {
var args = arguments
var that = this
clearTimeout(timer)
timer = setTimeout(function () {
fn.apply(that, args)
}, delay1)
}
}
引入这个防抖组件
- 这里没有使用箭头函数的原因是 会有this指向的问题 所以使用箭头函数
import { debounce } from '../utils/common'
用这个防抖
onInput: debounce(async function () {
const res = await GetTimeData({
keyword: this.inputVal
})
if (res.errno === 0) {
this.listArr = res.data
}
}, 200)
```---
# 主题列表:juejin, github, smartblue, cyanosis, channing-cyan, fancy, hydrogen, condensed-night-purple, greenwillow, v-green, vue-pro, healer-readable, mk-cute, jzman, geek-black, awesome-green, qklhk-chocolate
# 贡献主题:https://github.com/xitu/juejin-markdown-themes
theme: juejin
highlight:
---