<script>
export default {
data() {
return {
};
},
onShow() {
plus.android.requestPermissions(
['android.permission.ACCESS_FINE_LOCATION'],
function(resultObj) {
console.log(resultObj)
var result = 0;
for (var i = 0; i < resultObj.granted.length; i++) {
var grantedPermission = resultObj.granted[i];
console.log('已获取的权限:' + grantedPermission);
result = 1
}
for (var i = 0; i < resultObj.deniedPresent.length; i++) {
var deniedPresentPermission = resultObj.deniedPresent[i];
console.log('拒绝本次申请的权限:' + deniedPresentPermission);
result = 0
}
for (var i = 0; i < resultObj.deniedAlways.length; i++) {
var deniedAlwaysPermission = resultObj.deniedAlways[i];
console.log('永久拒绝申请的权限:' + deniedAlwaysPermission, a);
result = -1
}
},
function(error) {
console.log('申请权限错误:' + error.code + " = " + error.message);
}
);
}
};
</script>
或是将其写成方法放在methods中,依旧会反复申请
1 个回复
LGG233 - others
请问解决了吗