求大神解答 显示我setData错误?
data: {
headpic_path:'./images/touxiang.png',
},
getUserImg:function(){
wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths
console.log(tempFilePaths)
var that = this
that.setData({
headpic_path: tempFilePaths
})
}
})
},
VM8122:1 thirdScriptError
Cannot read property 'setData' of undefined;at api chooseImage success callback function
TypeError: Cannot read property 'setData' of undefined
console.log(tempFilePaths) 是可以显示出来路径的