Taro.navigateBack(option)
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.
Type
(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
// 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.
// This is Page A
Taro.navigateTo({
url: 'B?id=1'
})
// This is Page B
Taro.navigateTo({
url: 'C?id=1'
})
// Calling navigateBack on Page C will return to Page A
Taro.navigateBack({
delta: 2
})
API Support
| API | WeChat Mini-Program | H5 | React Native |
|---|---|---|---|
| Taro.navigateBack | ✔️ | ✔️ | ✔️ |