wx.getFileSystemManage.readFile报错?
发布于 7 年前 作者 qiangbai 6432 次浏览 来自 问答

在选择图片后使用wx.getFileSystemManage.readFile转化base64是出现报错:VM22195:1 readFile:fail parameter error: parameter.filePath should be String instead of Undefined

实在想不通啊!

代码如下:

user.chooseImage({
      count: 1,
      sizeType: ['compressed'],
      sourceType: ['album', 'camera'],
    })
    .then(res=>{
       // 选择图片成功,开始上传
       // 这里res是可以打印出来的
       console.log(res)
       //var filePath = res.tempFilePaths[0]
       return user.getFileSystemManagerReadFile({
        filePath: res.tempFilePaths[0], // 这里出现问题
        encoding: 'base64'
      })
    })
    .then(res=>{
      console.log('base64', res)
    })
    .catch(err=>{
      console.log('头像更新错误:', err)
    })
1 回复

我的不报错

回到顶部