export function debounce(fn, wait) {
let timer
return function() {
let context = this
let args = arguments
if (timer) clearTimeout(timer)
timer = setTimeout(fn.apply(context, args), wait)
}
}
会报错: setTimeout expects a function as first argument but got undefined.
下面为正确函数
export function debounce(fn, wait) {
let timer
return function() {
let context = this
let args = arguments
if (timer) clearTimeout(timer)
timer = setTimeout(() => {
fn.apply(context, args)
}, wait)
}
}
苹果小程序在处理时间 2020-12-29 14:19:32这类带“-”的时候,使用+ new Date会处理异常返回NaN,需要.replace(/-/g, "/")才可以正常转为时间戳
现已经上线体验版: 1