title: Taro.navigateBack(option)

sidebar_label: navigateBack

Closes the current page and returns to the previous page or multi-level page. The current page stack can be obtained via getCurrentPages to determine the number of layers to be returned.

Reference

Type

  1. (option?: Option) => Promise<CallbackResult>

Parameters

Option

Property Type Required Description
complete (res: CallbackResult) => void No The callback function used when the API call completed (always executed whether the call succeeds or fails)
delta number No Number of pages returned. The home page is navigated to if delta is greater than the current number of pages.
fail (res: CallbackResult) => void No The callback function for a failed API call
success (res: CallbackResult) => void No The callback function for a successful API call

Sample Code

  1. // Note: When calling navigateTo, the page that calls this method is added to the stack, but the redirectTo method will not. See the sample code below.
  2. // This is Page A
  3. Taro.navigateTo({
  4. url: 'B?id=1'
  5. })
  6. // This is Page B
  7. Taro.navigateTo({
  8. url: 'C?id=1'
  9. })
  10. // Calling navigateBack on Page C will return to Page A
  11. Taro.navigateBack({
  12. delta: 2
  13. })

API Support

API WeChat Mini-Program H5 React Native
Taro.navigateBack ✔️ ✔️ ✔️