- macOS 使用camera开发者工具闪退
使用macOS系统开发小程序,使用camera组件,开发者工具总是闪退,开通权限也不行 macOS:11.6 开发者工具:1.05.2201242 <template> <view> <view class="" v-if="isAuth"> <camera device-position="back" flash="auto" @error="error" style="width: 100%; height: 500upx;"> <cover-image src="../../static/scan-frame/scan-img.png" class="scan-img"></cover-image> </camera> </view> <view class="scan-text">请将XXX放置白色框内</view> <button type="primary" @click="takePhoto">拍照</button> <image mode="widthFix" class="photos-box" :src="src"></image> </view> </template> <script> export default { data() { return { src: '', isAuth: false }; }, onLoad() { let _ = this; wx.getSetting({ success(res) { if (!res.authSetting['scope.camera']) { wx.authorize({ scope: 'scope.camera', success() { _.isAuth = true; } }); } } }); }, methods: { takePhoto() { const ctx = uni.createCameraContext(); ctx.takePhoto({ quality: 'high', success: res => { this.src = res.tempImagePath; /* 返回调用页面并把图片URL传递过去 */ /* let pages = getCurrentPages(); let prevPage = pages[pages.length - 2]; prevPage.setData({ "image": res.tempImagePath, }) uni.navigateBack(); */ /* 调用页面获取图片URL方法 */ /* let pages = getCurrentPages(); let currPage = pages[pages.length-1]; if(typeof(currPage.data.image) != undefined && currPage.data.image != null){ console.log('获取图片:', currPage.data.image) } */ } }); }, error(e) { console.log(e.detail); } } }; </script> <style> .scan-img { opacity: 0.4; width: 100%; height: 500upx; } .scan-text { font-size: 20px; text-align: center; line-height: 60upx; } </style>
2022-02-22 - cover-image在ios设备上测试真机上不显示
https://developers.weixin.qq.com/miniprogram/dev/component/cover-image.html [图片] 使用的是云存储里的图片地址,开发工具预览里显示都是正常,放到真机上就看不到图片
2021-04-07