The parameter value of the data passed to the data when the WeChat applet returns to the previous page

1. When returning to the previous page, you need to pass the data to the corresponding parameter value in the data of the next page

Page B

  pageBack(){//放到返回上一页方法或成功的回调里面

    var pages = getCurrentPages();
    var prevPage = pages[pages.length - 2]; //上一个页面
    //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
    prevPage.setData({
      currentTab:0   //currentTab为上一页的data参数值,现在要一返回上一页就把其初始值为0
    })

 
  }

A page

data:{

currentTab:0 

}

 

Guess you like

Origin blog.csdn.net/asteriaV/article/details/111215026