小程序页面跳转传值和取值

跳转传值

  • 先看数据传递 *
1
<radio class='clickeds' value="{{item}}***{{index}}***{{hotList[index].id}}" checked="{{item.checked}}"/>
1
2
3
4
5
6
7
8
radioChange: function (e) {
console.log('radio发生change事件,携带value值为:', e.detail.value)
this.checkCard = e.detail.value;
var that = this;
that.setData({
botCardPrize: e.detail.value.split("&")[0]
});
},
1
2
3
4
5
topay:function(){
var that = this;
console.log( "选中的会员卡金额为: " + that.data.botCardPrize);
wx.navigateTo({ url: "../../pages/buyCard/buyCard?price=" + this.checkCard.split("&")[0] + "&name=" + this.checkCard.split("&")[1] + "&productId=" + this.checkCard.split("&")[2] + "&type=" + this.giftCard })
}

在这里radio先选中,然后赋值给data中的checkCard,然后点击付款按钮的时候进行传值并且跳转到付款页

在新页面接收数据

1
2
3
4
5
6
7
8
9
10
11
12
13
onLoad: function (options) {
let thisPrice = options.price*100;
let productName = options.name;
let id = options.productId;
let type = options.type;
let toPay = {
thisPrice: thisPrice,
productName: productName,
id: id,
type: type
};
this.payInfo = toPay;
},

option后面跟链接中的对应键解出值,组合成新的数据对象

-------------本文结束感谢您的阅读-------------
坚持原创技术分享,您的支持将鼓励我继续创作!