Wechat applet return problem

WeChat provides 5 jumping methods

1、wx.navigateTo(OBJECT)

  Keep the current page and jump to a page in the app

2、wx.redirectTo(OBJECT)

  Close the current page and jump to a page in the app.

3、wx.switchTab(OBJECT)

  Jump to the tabBar page and close all other non-tabBar pages

4、wx.navigateBack(OBJECT)

  Close the current page and return to the previous page or multi-level page.

5、wx.reLaunch(OBJECT)

  Close all pages and open to a page within the app.

 

When doing the return function, note that navigateBack does not call the onload method.

A workaround is provided below

1. Use navigateBack to jump without considering the page parameter problem, just setData directly

var pages = getCurrentPages(); //Get the current page
 var prePage = pages[pages.length - 2 ]; //Get the previous page
prePage.setData({
     'search.page': 1 //Assign the variable of the previous page
})
prePage.getPageData(); //Call the method of the previous page (load data)
wx.navigateBack({ //Return to the previous page
      delta: 1,
})

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324473339&siteId=291194637