ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
[TOC] #### 搜索节流 created() ~~~ import { debounce } from 'common/js/helpers' created() { // 监听query数据 this.$watch('content', debounce((newVal) => { this.$emit('inputVal', newVal) },200)) }, ~~~ >[danger] debounce 为节流函数 debounce ~~~ export function debounce (func, delay) { let timer return function (...args) { if (timer) { clearTimeout(timer) } timer = setTimeout(() => { func.apply(this, args) }, delay) } } ~~~