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

版权声明:署名-非商业性使用 转载请保留原文链接及作者。 https://blog.csdn.net/qq_40413396/article/details/85163564


跳转传值

  • 先看数据传递 *
<radio class='clickeds' value="{{item}}***{{index}}***{{hotList[index].id}}" checked="{{item.checked}}"/>
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]
    });
},
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,然后点击付款按钮的时候进行传值并且跳转到付款页

在新页面接收数据

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后面跟链接中的对应键解出值,组合成新的数据对象

猜你喜欢

转载自blog.csdn.net/qq_40413396/article/details/85163564