当前位置:网站首页>Wechat applet returns to the previous page and transfers parameters

Wechat applet returns to the previous page and transfers parameters

2022-06-10 14:32:00 yechaoa

     itemClick: function(e) {
          let pages = getCurrentPages();
          let prevPage = pages[pages.length - 2];
          prevPage.setData({
               message: e.currentTarget.dataset.msg,
          })
          wx.navigateBack({
               delta: 1,
          })
     },
  • getCurrentPages() Function to get an instance of the current page stack , Given as an array in the order of stacks
  • pages[pages.length - 2] It's the last page ,-1 It's the current page
  • Then directly call the... On the previous page setData Method
  • message Is the variable defined on the previous page ,e.currentTarget.dataset.msg Data to be transferred for the current page
  • And then call wx.navigateBack return ,delta Indicates the number of pages returned , If delta Greater than the number of existing pages , Then go back to the home page .

Wechat applet Close current page

原网站

版权声明
本文为[yechaoa]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206101411130756.html