wx.getSetting() 在用户点击地理位置授权后,打印授权信息undefined?
wx.getLocation({ type: 'wgs84' , success(res) { //维度 text[ "latitude" ] = res.latitude //经度 text[ "longitude" ] = res.longitude wx.setStorage({ key: "Location" , data: text }) }, complete(res) { console.log(res) wx.getSetting({ success: (res) => { console.log(res.authSetting) console.log(res.authSetting[ 'scope.userLocation' ]) console.log(!res.authSetting[ 'scope.userLocation' ]) if (!res.authSetting[ 'scope.userLocation' ]){ wx.showModal({ content: '检测到您没打开定位权限,为了活动体验是否去设置打开?' , confirmText: "确认" , cancelText: "取消" , success: function (res) { console.log(res); //点击“确认”时打开设置页面 if (res.confirm) { console.log( '用户点击确认' ) wx.openSetting({ success: (res) => { console.log(res) } }) } else { console.log( '用户点击取消' ) } }, complete() { } }); } else { } } }) } }) |
接口先调用wx.getLocation()后调用wx.getSetting()打印位置授权res.authSetting[
‘scope.userLocation’
]
undefined
这是啥情况啊?求解,有时候出来,有时候undefined就很郁闷.
基础库2.8.1 开发者工具 v1.02.1907301