wx.createCamera的回调函数中直接调用camera.takePhoto为什么不成功?
发布于 5 年前 作者 juanwan 1566 次浏览 来自 官方Issues

在wx.createCamera的回调函数success或者complete中调用camra.takePhoto获取到的返回对象tempImagepath为undefinded.示例代码:

camera.takePhoto(“normal”).then(

            res => {

              console.log(`tempImagePath===${res.tempImagePath}`)

              console.log(res)

}

)

延时调用camera.takePhoto是可以获取到tempImagePath. 示例代码:

        setTimeout(

          function () {

          camera.takePhoto(“normal”).then(

            res => {

              console.log(`tempImagePath===${res.tempImagePath}`)

              console.log(res)

            }

          )}, 1000)

但是感觉手动设置延时,并不是很准确,具体应该怎么判断什么时候可以调用camera.takePhoto

2 回复

你好,小游戏相关问题麻烦在小游戏专区提问,我们有专门的人员处理

小游戏专区:https://developers.weixin.qq.com/community/minigame

你为什么要初始化的时候就去拍照,什么需求

回到顶部