更新时间:2023-02-21 07:40:40
如果你想让 this
属性保持一致,你应该绑定被调用的函数.
If you want to have the this
property be consistent, you should bind the functions that are being called.
例如
setInterval(function() {/* code here */}.bind(this), 500)
这样,内部函数的this
将与外部函数的this
相同.
That way, the this
of the inner function will be the same as that of the outer function.