wkiwi的博客

微信小程序uploadFile返回数据为json字符串

发布时间:5年前热度: 2945 ℃评论数:

在小程序图片上传中发现返回的数据  为json字符串且  在network中Preview查看汉字为乱码


但是在console.log中正常且不乱码


在后台设置了统一返回json对象,但是前台始终显示字符串


需前端自行将字符转对象     


始终觉得是后台编码问题,真正答案有待商讨先做记录


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){

const data = SON.parse(res.data)

//do something } }) } })

微信,程序

手机扫码访问