Today, when I was using es6 to deconstruct the assignment introduction method, I found that I could not get the details of this, in the method.
paste code first:
/*mainVM*/
@observable planDetailList = [];
@action
ajaxPlanDetailList(id,callback){
Helper.ajax(Api.planList+"/"+id,{
method:"GET"
}).then(res => {
console.log(this);
})
}
/*componentDidMountmainVM*/
componentDidMount() {
const { ajaxPlanDetailList } = this.props.mainVM;
ajaxPlanDetailList(this.props.id);
}
displays the following error
mainVM
got the this
I don"t quite understand the reason. Please explain it in detail and kneel down and thank you
.