Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat Program API closes the current page and returns to the last page or multi-level page


May 19, 2021 WeChat Mini Program Development Document


Table of contents


wx.navigateBack(Object object)

Close the current page and return to the last or multi-level page. You can get the current page stack through getCurrentPages and decide how many layers you need to go back to.

Parameters

Object object

Property Type The default Required Description
delta number 1 Whether The number of pages returned, if delta is greater than the number of existing pages, is returned to the first page.
success function Whether The interface calls a successful callback function
fail function Whether The interface calls the failed callback function
complete function Whether Callback function at end of interface call (call succeeds, fails are executed)

The sample code


// 注意:调用 navigateTo 跳转时,调用该方法的页面会被加入堆栈,而 redirectTo 方法则不会。见下方示例代码

// 此处是A页面
wx.navigateTo({
  url: 'B?id=1'
})

// 此处是B页面
wx.navigateTo({
  url: 'C?id=1'
})

// 在C页面内 navigateBack,将返回A页面
wx.navigateBack({
  delta: 2
})