小程序
小游戏
企业微信
微信支付
扫描小程序码分享
camera组件ios设备使用takePhoto方法无返回结果
3 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
// 调取微信摄像头组件 <template> <camera v-if="showCamera" class="camera" device-position="front" :flash="flash" @error="erro" @stop="stop" > <cover-view> <cover-image class="face-bg-img" :style="{'height': height}" src="/static/img/face-bg.png" /> <cover-view class="take-photo" @click="takePhoto1"></cover-view> </cover-view> </template> <script> export default { name: "camera", props: { // 传参值 position: { type: String, default: "front", }, flash: { type: String, default: "off", }, quality: { type: String, default: "low", }, }, data() { return { showCamera: false, height: "auto,", }; }, watch: { showCamera() { if (this.showCamera) { this.$nextTick(() => { const query = wx.createSelectQuery(); query.select(".face-bg-img").boundingClientRect(); query.exec((res) => {}); }); } }, }, mounted() {}, methods: { error() { }, stop() { }, // 拍照 takePhoto1() { let that = this; const ctx = wx.createCameraContext(); ctx.takePhoto({ quality: this.quality, success(res) { console.log("success", res); this.showCamera = false; }, fail() { console.log("failed"); }, complete() { console.log("complter takePhoto!"); }, }); }, }, // 载入 onLoad() { this.showCamera = false; }, }; </script> <style lang="less"> .camera { position: fixed; top: 0; bottom: 0; left: 0; right: 0; z-index: 99; .face-bg { width: 100%; height: 100%; .take-photo { position: absolute; left: 50%; bottom: 50px; width: 80px; height: 80px; border-radius: 50%; background-color: rgba(255, 255, 255, 0.5); transform: translateX(-50%); display: flex; align-items: center; justify-content: center; } .face-bg-img { display: block; width: 100%; height: 100%; } } } </style>
提供一个代码片段,看看问题
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
这个问题也帮忙看看
// 调取微信摄像头组件 <template> <camera v-if="showCamera" class="camera" device-position="front" :flash="flash" @error="erro" @stop="stop" > <cover-view> <cover-image class="face-bg-img" :style="{'height': height}" src="/static/img/face-bg.png" /> <cover-view class="take-photo" @click="takePhoto1"></cover-view> </cover-view> </template> <script> export default { name: "camera", props: { // 传参值 position: { type: String, default: "front", }, flash: { type: String, default: "off", }, quality: { type: String, default: "low", }, }, data() { return { showCamera: false, height: "auto,", }; }, watch: { showCamera() { if (this.showCamera) { this.$nextTick(() => { const query = wx.createSelectQuery(); query.select(".face-bg-img").boundingClientRect(); query.exec((res) => {}); }); } }, }, mounted() {}, methods: { error() { }, stop() { }, // 拍照 takePhoto1() { let that = this; const ctx = wx.createCameraContext(); ctx.takePhoto({ quality: this.quality, success(res) { console.log("success", res); this.showCamera = false; }, fail() { console.log("failed"); }, complete() { console.log("complter takePhoto!"); }, }); }, }, // 载入 onLoad() { this.showCamera = false; }, }; </script> <style lang="less"> .camera { position: fixed; top: 0; bottom: 0; left: 0; right: 0; z-index: 99; .face-bg { width: 100%; height: 100%; .take-photo { position: absolute; left: 50%; bottom: 50px; width: 80px; height: 80px; border-radius: 50%; background-color: rgba(255, 255, 255, 0.5); transform: translateX(-50%); display: flex; align-items: center; justify-content: center; } .face-bg-img { display: block; width: 100%; height: 100%; } } } </style>
提供一个代码片段,看看问题