setTimeout传参问题
2020-06-08 本文已影响0人
玲儿珑
IE8下参数接受失败的解决方案:
var __sto = setTimeout
window.setTimeout = function(cb, timeout, ...args){
var args = Array.prototype.slice.call(arguments, 2)
var _cb = function () {
cb.apply(null, args)
}
__sto(_cb, timeout)
}
//测试
function aa (a, b, c) {
console.log(a)
console.log(b)
console.log(c)
}
window.setTimeout(aa, 200, 1,4,5)