const func = function (e){
console.log('e:', e)
console.log('timeupdate!')
localStorage.setItem('currentTime', this.currentTime)
}
function throttle(func,wait = 0){
// 使用节流优化
let timeId
return function(...args){}
if(timeId !== undefined){
return
}
const _this = this
timeId = setTimeout(()=>{
func.apply(_this,args)
timeId = undefined
},wait)
}
const throttleFn = throttle(func,1000)
video.addEventListener('timeupdate',throttleFn)
注意:_this=this中的this指向video