前端通用函数(建议收藏)
节流函数
–规定在一个单位时间内,只能触发一次函数。如果这个单位时间内触发多次函数,只有一次生效。
function throttle(fun, delay) {
let last, deferTimer
return function (args) {
let that = this
let _args = arguments
let now = +new Date()
if (last && now <
原创
2020-07-03 10:01:16 ·
1110 阅读 ·
0 评论