小程序有两个mapContext实例,先创建的实例API不执行
发布于 5 年前 作者 wei36 1228 次浏览 来自 问答

小程序有两个页面 index 和adv ,每个页面都使用了map组件,并且在onLoad函数里创建了mapContext,

index.wxml

<map id="qqMap" style=“width: 100%; height: {{screenHeightMap}}px;” latitude="{{latitude}}" longitude="{{longitude}}" markers="{{markers}}" bindmarkertap=“showTipWin” bindtap=“closeTipWin” bindregionchange=“regionchange”  bindcallouttap=“btnCallout” show-location>

index.js  

onLoad: function (option) {  

   this.mapCtx = wx.createMapContext(‘qqMap’);

 },

adv.wxml  

<map id="advMap"style=“width: 100%; height: 190px;” latitude="{{latitude}}" longitude="{{longitude}}" markers="{{markers}}" show-location circles="{{circles}}" bindtap=“ontapstart” bindregionchange=“regionchange”>

adv.js

onLoad: function (options) {

   this.mapCtxAdv = wx.createMapContext(‘advMap’);

     }, 

微信小程序开发工具,基础库 2.3.0

编译完成后,首先进入的是index 页面,此时mapCtx下的所有API函数都正常,当跳转到adv页面后,再跳转回到index页面,则mapCtx下的所有API都不执行了

有哪位大神遇到过这种情况,求大神帮忙,非常感谢

回到顶部