1.检查appid是没有问题的
2.最后分析可能是初始化还没完成,就去调了微信相关的api,所以尝试用setTimeout加延时,问题解决(如果微信初始化跟wx.getLocation相差时间很短,可适当延长延时时间)
setTimeout(() =>{
wx.getLocation({
type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
success: res => {
},
fail: res => {
console.error(res);
}
});
},1000)
网友评论