小程序在开发者工具上真机调试能正常拍照,为什么发布后拍照不能取到图片?
发布于 4 年前 作者 kzhang 290 次浏览 来自 问答

第一张图为拍照前,第二张图为在开发者工具上真机调试,第三张图为发布后通过小程序打开。

也就是说在开发者工具上一切正常,没有任何问题,但发布后功能就不能正常使用了,拍照后的图片读取不出来,想请问下是权限问题还是代码原因?

以下是部分代码

<view v-if=“isphoto”>

		&lt;camera device-position="back" flash="auto" [@error](/user/error)="error" style="width: 100%; height: 500upx;"&gt;

			&lt;cover-image src="../../static/scan-frame/scan-img.png" class="scan-img"&gt;&lt;/cover-image&gt;

		&lt;/camera&gt;

		&lt;view class="scan-text"&gt;请将身份证正面放置白色框内&lt;/view&gt;

		&lt;u-button type="primary" [@click](/user/click)="takePhoto"&gt;拍照&lt;/u-button&gt;

	&lt;/view&gt;

	&lt;view&nbsp; v-if="!isphoto"&gt;

		&lt;image mode="widthFix" class="photos-box" :src="src"&gt;&lt;/image&gt;

		&lt;button type="primary" [@click](/user/click)="isphoto=true"&gt;重新拍照&lt;/button&gt;

	&lt;/view&gt;

 

	takePhoto() {

			this.isphoto=false;

			const ctx = uni.createCameraContext();

			ctx.takePhoto({

				quality: 'high',

				success: (res) =&gt; {

					this.src = res.tempImagePath;

					})

				}

			});

		},
回到顶部