求大神解答 显示我setData错误?

发布于 6 年前作者 pwan10028 次浏览最后编辑 6 年前来自 ask
  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) 是可以显示出来路径的

1 回复
ojiang
ojiang1 楼4 年前

你放里面怎么想的