You can register a Mini Program instance by invoking the App method in app.js. app.js is the first JavaScript file executed in the entire Mini Program.
// app.js
App()
You can provide certain parameters within App. For detailed parameter descriptions and usage, please refer to the App Reference. However, using App parameters is not recommended; instead, other methods should be used.
Typically, global event handler functions can be placed in app.js, for example:
App()
wx.onPageNotFound((res) => {
// Triggered when a page is not found
})
It is not recommended to place global variables and JavaScript modules in `app.js`. Instead, it is recommended to maintain them using <a href="module" target="_blank">Modularization</a>.