普通函数

const current= this

retryCancelOrder().then(

function(result){

//通过current获取this

current.orderNumber

//这边的this指向的是function(result)

})

 

箭头函数

retryCancelOrder().then(

(result)=>{

// 自动修复this的指向

this.orderNumber

})

 

箭头函数没有自己的this值,箭头函数中所使用的this来自于函数作用域链。

posted on 2020-09-08 17:35  jeffh  阅读(210)  评论(0编辑  收藏  举报