Skip to main content
Version: Next

Taro.navigateTo(option)

Keeps the current page open and redirects to a page (except for the tabbar page) in the app. You can return to the original page using Taro.navigateBack. The page stack in the WeChat Mini-Program is limited to ten layers.

Reference

Type

(option: Option) => Promise<CallbackResult>

Parameters

Option

PropertyTypeRequiredDescription
urlstringYesPath to a non-tabBar page to be navigated to in the app. Parameters can be appended after the path. You can use ? to separate the path from parameters, = to connect a parameter key with a parameter value, and & to separate different parameters. For example, 'path?key=value&key2=value2'.
complete(res: CallbackResult) => voidNoThe callback function used when the API call completed (always executed whether the call succeeds or fails)
eventsRecord<string, any>NoInter-page communication interface for listening to data sent to the current page by the opened page.
fail(res: CallbackResult) => voidNoThe callback function for a failed API call
success(res: CallbackResult) => voidNoThe callback function for a successful API call

Sample Code

Taro.navigateTo({
url: 'test?id=1',
events: {
acceptDataFromOpenedPage: function(data) {
console.log(data)
},
someEvent: function(data) {
console.log(data)
}
...
},
success: function (res) {
res.eventChannel.emit('acceptDataFromOpenerPage', { data: 'test' })
}
})

API Support

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