Skip to main content

为什么不能直接 promise.then 返回值为 this

var p1 = Promise.resolve(42)
p1.then(function () {
console.log(this)
return this //指向全局
})
//Window {0:global…}

因为 this 指向全局 window,所以不能设为 this