今天遇见一个问题,wx.chooseImage()在iOS手机上调用不起来,在安卓手机上是正常的,所以加了一个Input调用摄像头
<div v-if="isiOS" class="signIn" @click="selectPhotoClick"> <input id="img_name" type="file" accept="image/*" capture="user" multiple hidden @change="selectPhoto"></input> </div>
selectPhoto(e) { let _this = this; const file = e.target.files[0]; this.selectedImage = file; const reader = new FileReader(); reader.onload = (e) => { const base64Image = e.target.result; _this.cropImage(base64Image); // 在这里处理转换后的Base64编码的图片 }; reader.readAsDataURL(file); }, selectPhotoClick() { document.getElementById("img_name").click(); return false },
实现了IOS调用手机摄像头的效果