解决方案:
<camera mode="normal" device-position="back" frame-size="small" binderror="onError" style="height: 70vh;width: 100%;" resolution="medium">
监听binderror事件 在事件内执行以下方法
wx.showModal({
title: '提示',
content: '尚无相机权限,前往授权?',
success :(res)=> {
if (res.confirm) {
wx.openSetting({
success:(res)=>{
if (res.authSetting["scope.camera"]) {
wx.redirectTo({
url: 'xxx' // 重新刷新一下当前页面就直接重新执行了
})
}
}
});
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})