takePhoto 测试环境 请问为啥报下面错误,怎么办?

发布于 7 年前作者 xiongqiang8818 次浏览最后编辑 7 年前来自 ask

takePhoto() {

   const ctx = wx.createCameraContext()

   ctx.takePhoto({

     quality: ‘high’,

     success(res) {

       console.log(‘success’)

       console.log(res)

     },

     fail(res) {

       console.log(‘takePhoto fail res’)

       console.log(res)

     }

 

   })

<!-- camera.wxml –>

<camera device-position=“back” flash=“off” binderror=“error” style=“width: 100%; height: 300px;”></camera><button type=“primary” bindtap=“takePhoto”>拍照</button><view>预览</view><image mode=“widthFix” src=“{{src}}”></image>

Cannot read property ‘mode’ of undefined;at pages/take_video/video page takePhoto function

TypeError: Cannot read property ‘mode’ of undefined

4 回复
panyang
panyang1 楼6 年前

版本问题,2.04版本camera有问题,可以切换成最新版本

xiangyan
xiangyan2 楼6 年前

咋回事呢

sunqiang
sunqiang3 楼6 年前

mode=>查看下这个定义是什么?

yankong
yankong4 楼5 年前

我这边预览是正常的