8月前上线的时候,开发工具和真机测试功能都是正常的,近期测试的时候发现该功能在开发工具中正常,真机异常,并提示错误{"errMsg":"moveToMapLocation:fail:mapview is null")
以下是代码片段:
onReady() {
this.initMapContext();
},
methods: {
initMapContext() {
const query = uni.createSelectorQuery().in(this);
query
.select("#map")
.fields({ context: true }, (res) => {
if (res.context) {
this.mapCtx = res.context;
}
})
.exec();
},
goToCurrentLocation() {
this.mapCtx.moveToLocation();
}
}

你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
已经解决了,官方回答都是片面的。
只需要在调用失败的时候,延迟1秒在循环调用就可以了。
可能是部分手机性能不佳导致第一次moveToLocation失败