Taro.switchTab(option)
Redirects to the tabBar page and closes all non-tabBar pages.
Type
(option: Option) => Promise<CallbackResult>
Parameters
Option
| Property | Type | Required | Description | 
|---|---|---|---|
| url | string | Yes | Path to the tabBar page (a page to be defined in the tabBar field of app.json) to be navigated to. Parameters cannot be appended after the path. | 
| complete | (res: CallbackResult) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) | 
| 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
{
  "tabBar": {
    "list": [{
      "pagePath": "index",
      "text": "Home"
    },{
      "pagePath": "other",
      "text": "Other"
    }]
  }
}
Taro.switchTab({
  url: '/index'
})
API Support
| API | WeChat Mini-Program | H5 | React Native | 
|---|---|---|---|
| Taro.switchTab | ✔️ | ✔️ | ✔️ |