像我这样,同一个页面有两个地方需要用到地图选点的插件,那么onshow中怎么区分这两个地图的选点呢?
onShow: function () {
wx.hideHomeButton();
const location = chooseLocation.getLocation(); // 如果点击确认选点按钮,则返回选点结果对象,否则返回null
console.log('location:'+location.address)
this.setData({
address1:location.address
})
},
点哪个就记录一下 targetAddress呗 wx.setStorageSync('targetAddress', 'address1') 选择地址返回后 tar = wx.getStorageSync('targetAddress') || '' tar != '' && this.setData({ [tar]: location.address });
若认为该回答有用,给回答者一个[ 有用 ]吧!
点击装货地址时,设置targetAddress为address1
点击卸货地址时,设置targetAddress为address2
在onShow里直接读取targetAddress的值
然后setData就好了,明白?
onShow:()=>{
tar = wx.getStorageSync('targetAddress') || ''
tar != '' && this.setData({
[tar]: location.address
});
}