Skip to main content
Version: 3.x

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.

Reference

Type

(callback: Callback) => void

Parameters

Result

PropertyTypeDescription
isEntryPagebooleanIndicates 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).
pathstringThe path to the nonexistent page
queryRecord<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
PropertyType
resResult

API Support

APIWeChat Mini-ProgramH5React Native
Taro.onPageNotFound✔️