调用微信小程序的接口wx.getLocation(Object object),会给出以下提示
解决办法
位置授权要先在app.json里声明一下,在app.json中加入以下这段代码
"permission": {
"scope.userLocation": {
"desc": "山东省济南市历城区"
}
}
整个app.json如下所示
{
"pages": [
"pages/index/index",
"pages/about/about",
],
"window": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "贴身管家",
"navigationBarBackgroundColor": "#fbf9fe",
"backgroundColor": "#fbf9fe"
},
"tabBar": {
"color": "#999999",
"selectedColor": "#009be0",
"borderStyle": "black",
"backgroundColor": "#ffffff",
"list": [
{
"pagePath": "pages/index/index",
"iconPath": "images/shouye1.png",
"selectedIconPath": "images/shouye.png",
"text": "首页"
},
{
"pagePath": "pages/weather/weather",
"iconPath": "images/tianqi1.png",
"selectedIconPath": "images/tianqi.png",
"text": "天气"
},
{
"pagePath": "pages/about/about",
"iconPath": "images/guanyu1.png",
"selectedIconPath": "images/guanyu.png",
"text": "关于"
}
]
},
"permission": {
"scope.userLocation": {
"desc": "你的地址信息"
}
},
"networkTimeout": {
"request": 10000,
"connectSocket": 10000,
"uploadFile": 10000,
"downloadFile": 10000
},
"debug": true,
"sitemapLocation": "sitemap.json"
}