求大神解答 显示我setData错误?
发布于 4 年前 作者 pwan 9770 次浏览 来自 问答
  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 回复

你放里面怎么想的

回到顶部