wx.createCamera的回调函数中直接调用camera.takePhoto为什么不成功?

发布于 7 年前作者 juanwan1788 次浏览最后编辑 7 年前来自 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 回复
li06
li061 楼6 年前

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

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

cduan
cduan2 楼5 年前

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