Skip to main content
Version: Next

Taro.switchTab(option)

Redirects to the tabBar page and closes all non-tabBar pages.

Reference

Type

(option: Option) => Promise<CallbackResult>

Parameters

Option

PropertyTypeRequiredDescription
urlstringYesPath 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) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
fail(res: CallbackResult) => voidNoThe callback function for a failed API call
success(res: CallbackResult) => voidNoThe 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

APIWeChat Mini-ProgramH5React Native
Taro.switchTab✔️✔️✔️