- self
function () {
let self = this
setTimeout(function() {
// self.prop
}, 1000);
}
- 箭头函数
function() {
setTimeout(() => {
this.prop //此时this等同于function的this
}, 1000);
}
- bind
function() {
setTimeout(function() {
this.prop //this等同于外层function的this
}.bind(this), 1000);
}