computed: {
listen_change() {
const { value01, value02 } = this
return { value01, value02 }
},
}
// 放到工具類的函數(shù)防抖動
export function debounce(func, delay) {
let timer;
return function(...args) {
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(() => {
func.apply(this, args);
}, delay);
};
}
//使用方式
this.$watch(
'listen_change',
debounce((newValue, oldValue) => {
//todo
}, 500)
)