当前位置:   article > 正文

uni-app 获取手机存储权限_uniapp获取存储权限

uniapp获取存储权限
  1. beforeExport() {
  2. // 判断有没有存储权限
  3. var _this = this
  4. plus.android.requestPermissions(['android.permission.WRITE_EXTERNAL_STORAGE'], function(e) {
  5. if (e.deniedAlways.length > 0) { //权限被永久拒绝
  6. // 弹出提示框解释为何需要读写手机储存权限,引导用户打开设置页面开启
  7. uni.showModal({
  8. title: '存储权限',
  9. content: '您拒绝了存储权限,请前往设置-应用开启存储权限。',
  10. success: function(res) {
  11. if (res.confirm) {
  12. // console.log('用户点击确定');
  13. } else if (res.cancel) {
  14. // console.log('用户点击取消');
  15. }
  16. }
  17. });
  18. }
  19. if (e.deniedPresent.length > 0) { //权限被临时拒绝
  20. // 弹出提示框解释为何需要读写手机储存权限,可再次调用plus.android.requestPermissions申请权限
  21. plus.android.requestPermissions(['android.permission.WRITE_EXTERNAL_STORAGE'])
  22. }
  23. if (e.granted.length > 0) { //权限被允许
  24. //调用依赖获取读写手机储存权限的代码
  25. _this.exportFile()
  26. }
  27. }, function(e) {
  28. });
  29. },

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/42138
推荐阅读
相关标签
  

闽ICP备14008679号