Solution to the disappearance of shopping cart data when refreshing the WeChat applet

First obtain the shopping cart data in onload through the interface and render it,
and then save the shopping cart data locally


  wx.setStorageSync('cart', res.data.data[0].orderItemList)

Then take it out in onShow

   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
    
 var shoplist=wx.getStorageSync('cart')
 this.setData({
    
    
   shoplist:shoplist
 })
 this.prix()
  },

That's it

Guess you like

Origin blog.csdn.net/wsxDream/article/details/112278876