createCameraContext
发布于 4 年前 作者 wei11 400 次浏览 来自 问答

wx.createCameraContext()调用takePhoto返回的res.tempImagePath怎么转成base64的图片???

2 回复

这个返回的是照片文件的临时路径,暂不支持此功能

 wx.createCameraContext().takePhoto({

    quality: ‘high’,

    success: (res) => {

      let tempImagePath = res.tempImagePath

 

      wx.getFileSystemManager().readFile({

        filePath: tempImagePath,

        encoding: ‘base64’,

        success: (res) => {

          let avatarBase64 = res.data

          console.log(avatarBase64)

          wx.hideLoading()

        }

      })

    }

  })

回到顶部