首先需要一个js的sdk:App权限判断和提示 - DCloud 插件市场
下载下来,引入里面的 permission.js
示例代码:
<script>
import { requestAndroidPermission } from './sdk/permission.js'
export default {
onLaunch(e) {
const getMutiPermission = async () => {
await that.requestAndroidPermission('android.permission.CAMERA')
await that.requestAndroidPermission('android.permission.READ_EXTERNAL_STORAGE')
await that.requestAndroidPermission('android.permission.WRITE_EXTERNAL_STORAGE')
}
getMutiPermission()
},
methods:{
async requestAndroidPermission(permisionID) {
var result = await requestAndroidPermission(permisionID)
}
}
}
</script>
确保把这个打开: