We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
防抖函数debounce在setTimeout中通过apply执行的函数(debounce第一个参数)中的this(apply第一个参数)测试为undefined,感觉应该在debounce中传入一个'this'(项目中为this.$refs.scroll) // 防抖函数 export function debounce(func, that = null, delay = 500) { // 回调函数,和回调函数要执行须等待的时间ms let timer = null // this => Vue组件 return function (...args) { // this => undefined if (timer) { clearTimeout(timer) } timer = setTimeout(() => { // 测试证明此处使用this => undefined func.apply(that, args) //func() }, delay) } }
// 防抖函数 export function debounce(func, that = null, delay = 500) { // 回调函数,和回调函数要执行须等待的时间ms let timer = null // this => Vue组件 return function (...args) { // this => undefined if (timer) { clearTimeout(timer) } timer = setTimeout(() => { // 测试证明此处使用this => undefined func.apply(that, args) //func() }, delay) } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
防抖函数debounce在setTimeout中通过apply执行的函数(debounce第一个参数)中的this(apply第一个参数)测试为undefined,感觉应该在debounce中传入一个'this'(项目中为this.$refs.scroll)
// 防抖函数 export function debounce(func, that = null, delay = 500) { // 回调函数,和回调函数要执行须等待的时间ms let timer = null // this => Vue组件 return function (...args) { // this => undefined if (timer) { clearTimeout(timer) } timer = setTimeout(() => { // 测试证明此处使用this => undefined func.apply(that, args) //func() }, delay) } }
The text was updated successfully, but these errors were encountered: