- ios端小程序页面非第一次onLoad调起相机不起作用?
// 小程序 ios端调起相机与相册无反应 只有第一次onload可以调起 之后进入页面切onload方法执行后未调起相机 需重新进入小程序可可以正常调起相机 <template> <view class="publish"> aaaaaaa <image mode="widthFix" class="img" :src="imgSrc"></image> </view> </template> <script> export default { data() { return { text: '', imgSrc: '', file: null, activityId: '', isShowTextMaxLength: false, sourceType: null, } }, onShow(option) { }, onLoad(option) { wx.chooseMedia({ count: 5, sourceType: ['album'], mediaType: ['image'], success: (data) => { let file = data.tempFiles[0]; let filePath = file.tempFilePath; file.path = file.tempFilePath; file.type = "image"; file.thumb = file.path; file.url = file.path; this.imgSrc = filePath; this.file = file; }, fail(err) { uni.navigateBack(); }, complete() { }, }) }, methods: { } } </script> <style scoped lang="scss"> </style>
2024-02-26 - 小程序 ios端调起相机与相册无反应 只有第一次onload可以调起 之后需重新进入小程序
onLoad(option) { this.activityId = option.activityId; this.sourceType = option.isCamera == 'false' ? ['album'] : ['camera']; wx.chooseMedia({ count: 1, sourceType: this.sourceType, mediaType: ['image'], success: (data) => { let file = data.tempFiles[0]; let filePath = file.tempFilePath; file.path = file.tempFilePath; file.type = "image"; file.thumb = file.path; file.url = file.path; this.imgSrc = filePath; this.file = file; }, fail(err) { uni.navigateBack(); }, complete() { }, }) },
2024-02-26