注意:es6箭头函数没有this
//注意:es6箭头函数没有this
bindPickerRoleChange: (e)=>{
console.log(this);//输出undefined
//this当前为undefined,会报错;Cannot read property 'data' of undefined;
this.setData({
RoleValue: 3
})
}
},
//正确方法
bindPickerRoleChange: function(e) {
console.log(this);//输出this对象
//正常赋值
this.setData({
RoleValue: 3
})
}
}