Micro-channel applet passing objects (array)

      After the array passed from interface to obtain needed passed to the next page, need var items = JSON.stringify (res.data) of this code into a string object.


  search: function (res) {
    console.log("搜索信息---" + this.data.searchValue)
    var self = this
    wx.request({
      url: 'http://127.0.0.1:8080/fybpi/pi.Goods.search.hf',
      data: {
        MemberID: 1              ,                //用户编号 
        goodName: this.data.searchValue            //搜索内容     
      },
      method: 'POST',
      dataType: 'json',
      success: function (res) {
        var items = JSON.stringify(res.data);
        self.setData({
          items: res.data
        })
        if (res.data.length != 0) {
          var url = '../home/search/search?items=' + items;
        }
        else {
          var url = '../home/searchno/searchno';
        }
        wx.navigateTo({
          url: url,
        })
      }
    })
  },

Passed to the second page. JSON.parse (this.options.items) by this code var items =; operates to convert a string object. (Content code received on the onload pages are options.items, onshow a need to add this)

onShow: function (options) {
    var self = this
    var items = JSON.parse(this.options.items);
    console.log("search show", items)
    self.setData({
      items: items
    })
  },

 

Guess you like

Origin blog.csdn.net/qq_39404258/article/details/90479569