微信小程序——返回上个页面带参数
当前页面:
var pages = getCurrentPages(); //当前页面
var prevPage = pages[pages.length - 2]; //上一页面
prevPage.setData({
//直接给上一个页面赋值
addresschose: that.data.address[index],
});
wx.navigateBack({
//返回
delta: 1
})
要跳转的页面:
onShow: function () {
let that = this;
let pages = getCurrentPages();
let currPage = pages[pages.length - 1];
if (currPage.data.addresschose) {
that.setData({
//将携带的参数赋值
address: currPage.data.addresschose,
addressBack: true
});
console.log(that.data.address, '地址')
}
}