小程序页面跳转传参

220 阅读1分钟

例1

 goProduct(e) {
    console.log(e)
    let index = e.currentTarget.dataset.index
    wx.navigateTo({
      // 跳转传参
      url: '../fund_product/fund_product?c_fundcode=' + this.data.show_data[index].c_fundcode
    })
  },

'c_fundcode'是自定义的名字,this.data.show_data是数组 index是下标 c_fundcode是具体传的参数

例2

  toList:function(e) {
    console.log(e)
    let index = e.currentTarget.dataset.index + 2
    wx.redirectTo({
      url: '../fund_list/fund_list?index=' + index,
    })
  },

传下标

接收

 onLoad: function(options) {
    let that = this
    that.setData({
      chooseIndex: options.index
    })
    this.init()
  },

例3

goProduct(e) {
    console.log(e)
    // let index = e.currentTarget.dataset.index
    let c_fundcode = this.data.show_data[e.currentTarget.dataset.index].c_fundcode
    let c_fundname = this.data.show_data[e.currentTarget.dataset.index].c_fundname
    wx.navigateTo({
      // 跳转传参
      url: '../fund_product/fund_product?fundCode=' + c_fundcode + "&fundNmae=" +  c_fundname
    })
  },