微信小程序获得权限喜欢搞混的
编辑时间:2020-11-27 作者:金满斗 浏览量:1229 来源:原创

看代码吧,搞个小程序,要用到录音功能,怕别人把权限关了要判断下。结果因为一不注意搞了半天。

直接上代码吧。

uni.showModal({
title: '麦克风权限未授权',
content: '请打开麦克风权限,不然语音输入无法识别',
complete:()=>{
let that = this;
uni.openSetting({
  success(res) {
    let scope = (res.authSetting);
if(scope['scope.record'] == true){
that.manager = plugin.getRecordRecognitionManager()
that.listenRecordLnit();
that.openVoice = true ;
that.isplugin = true ;
}
  }
});

}
})


这里scope['scope.record'] 容易混,开始scope.scope.record  调试了半天说怎么不对了。

哎,大意了,腾讯程序员不讲武德,我劝他们耗子尾之。


来说两句吧