微信小程序wx.uploadFile上传图片以后setData没有作用

wx.chooseImage({
  success (res) {
    const tempFilePaths = res.tempFilePaths
    wx.uploadFile({
      url: 'https://example.weixin.qq.com/upload', //仅为示例,非真实的接口地址
      filePath: tempFilePaths[0],
      name: 'file',
      formData: {
        'user': 'test'
      },
      success (res){
        var data = JSON.parse(res.data);
 //此处应该如此转换后才可以用setData赋值,否则setData失效报错
        var thimg = data.msg;
        that.setData({
            comimg: thimg
        })

        
      }
    })
  }
})

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章