17 lines
299 B
JavaScript
17 lines
299 B
JavaScript
|
|
||
|
export const Debounce = (func, delay) => {
|
||
|
let timer;
|
||
|
|
||
|
return function() {
|
||
|
const context = this;
|
||
|
const args = arguments;
|
||
|
clearTimeout(timer);
|
||
|
uni.showLoading({
|
||
|
title: '加载中...'
|
||
|
})
|
||
|
timer = setTimeout(() => {
|
||
|
func.apply(context, args);
|
||
|
uni.hideLoading()
|
||
|
}, delay);
|
||
|
};
|
||
|
}
|