//防抖debounce(fn, time = 1000) {let timer = null;return function (...args) {if (timer) clearTimeout(timer);timer = setTimeout(() => {fn.apply(this, args);}, time);};},// 输入变化处理函数async inputChange(value) {if (!this.debouncedInputChange) {this.debouncedInputChange = this.debounce(this.handleInputChange, 1000);}this.debouncedInputChange(value);},// 实际处理输入变化的函数async handleInputChange(value) {const res = await baseOptionApi.getDetailByProcessTaskIdLike({ processTaskIdLike: value });let myrange = [];res.data.data.forEach((val, index) => {myrange.push({...val, // 保留原始数据的所有字段value: val.processTaskId, // 选项idtext: val.processTaskId + '-' + val.processName // 选项名称});});this.processIdOption = myrange;},
参考彻底理清防抖和节流(前端性能优化)_防抖节流-CSDN博客