直接看图吧
点击获取位置权限同意后还是默认的值,没有改变。。。
本来预期的表现应该是这样的
应该是点击后会自动跳转当前城市,但是不管我是同意还是拒绝后的操作,位置都没变,还是默认值“广州市”,请问这怎么解决?
我重复一下实现的步骤,一开始的页面是这样
然后点击获取当前位置,出现如下提示页面:
点击确定后,应该出现我所在城市的名字:
在开发者工具上一切都正常跳转,但是真机上面一点击就出现图一那种情况,请问这到底是怎么回事啊?
我再把代码附上,请帮我检查一下,谢谢各位大神
onTapLocation() {
if (this.data.locationAuthType === UNAUTHORIZED)
wx.openSetting()
else
this.getLocation()
},
getLocation () {
wx.getLocation({
success: res => {
this.setData({
locationAuthType: AUTHORIZED,
})
this.qqmapsdk.reverseGeocoder({
location: {
latitude: res.latitude,
longitude: res.longitude
},
success: res =>{
let city = res.result.address_component.city
this.setData({
city: city,
locationTipsText: ""
})
this.getNow()
}
})
},
fail: ()=> {
this.setData ({
locationAuthType: UNAUTHORIZED,
})
}
})
}
})