小程序选择门店后带参返回上一页
子页(需要选择的):
wxml:
js:
// 选择门店回上一页(首页) backIndex: function (e) { console.log('回首页!!!!') var me = this; let idindex = e.currentTarget.dataset.id; var stores = me.data.data.data; var dis = stores[idindex].dis var id = stores[idindex].id console.log(stores) console.log(idindex) console.log(dis) console.log(id) App._post_form('Storeinfo/sele', {id: id,km: dis}, result => { var touch_data = result.data.data; var touch_id = touch_data.id; var touch_store_name = touch_data.store_name; me.setData({ touch_data: touch_data, touch_id: touch_id, touch_store_name: touch_store_name, }) var pages = getCurrentPages(); var prevPage = pages[pages.length - 2]; //上一个页面 //直接调用上一个页面的setData()方法,把数据存到上一个页面中去 prevPage.setData({ mydata: { touch_id: touch_id, touch_store_name: touch_store_name, } }) wx.navigateBack({//返回 delta: 1 }) }, false, () => { wx.hideLoading(); }); },父页(需要选择后显示的):
wxml:
参考链接:https://www.cnblogs.com/ldlx-mars/p/10598708.html