Taro.onPageNotFound(callback)
Listens on the event that a page to be opened by the Mini Program does not exist. The callback timing for this event is consistent with that of App.onPageNotFound
.
NOTE
- Developers can implement page redirection during callback only when the callback processing is synchronous. This approach is invalid for asynchronous processing (such as the asynchronous execution of setTimeout).
- If the developer neither calls the Taro.onPageNotFound for listening nor declares App.onPageNotFound, when the redirected page does not exist, the WeChat app's native 404 page is pushed.
- If the callback redirects to another page that does not exist, the WeChat app's native 404 page is pushed and the API is not called back again.
Type
(callback: Callback) => void
Parameters
Result
Property | Type | Description |
---|---|---|
isEntryPage | boolean | Indicates whether this is the first page for this launch (for example, from sharing and other entries, the first page is the shared page configured by the developer). |
path | string | The path to the nonexistent page |
query | Record<string, any> | The query parameter for the nonexistent page |
Callback
The callback function for the event that a page to be opened by the Mini Program does not exist.
(res: Result) => void
Property | Type |
---|---|
res | Result |
API Support
API | WeChat Mini-Program | H5 | React Native |
---|---|---|---|
Taro.onPageNotFound | ✔️ |