[微信小程序]页面跳转对象参数的传递方法

微信小程序中,使用

wx.reLaunch({

      url:'../index/index?id='+this.data.id+'&list='+list,

      success:function(res){

       console.log('ok')

      },

      fail:function(res){},

      complete:function(res){},

    })

进行页面间参数传递,当str为对象时

onLoad:function(options){

    //页面初始化 options为页面跳转所带来的参数

     this.setData({

      id:options.id,

      list:options.list

    })

  },

会发现在跳转后页面解析失败



解决方案:

原页面:

letstr=JSON.stringify(this.data.list);

    wx.reLaunch({

      url:'../index/index?id='+this.data.id+'&list='+str,

      success:function(res){

       console.log('ok')

      },

      fail:function(res){},

      complete:function(res){},

    })

跳转后的页面加载代码:

onLoad:function(options){

    //页面初始化 options为页面跳转所带来的参数

    letitem=JSON.parse(options.list);

     this.setData({

      id:options.id,

      list:item

    })

  },


转载请注明出处


猜你喜欢

转载自blog.csdn.net/cargelzhong/article/details/77073832