html52.com
我爱小程序-开发者交流社区

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

在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

网友回复

undefined:

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

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付