docs: improve enhanceApp usecases (#5315)

pull/5318/head
Bjorn Lu 2 months ago committed by GitHub
parent dcb7a75532
commit e558af6ca0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -62,11 +62,14 @@ import Layout from './Layout.vue'
export default {
Layout,
enhanceApp({ app, router, siteData }) {
// ...
// app.component(...)
// app.use(...)
}
}
```
The `enhanceApp` hook allows you to access the [Vue app instance](https://vuejs.org/api/application.html) and other runtime data, which can be used to [register global components](./extending-default-theme.md#registering-global-components), integrate with Vue libraries, etc.
The `router` value is the same VitePress router instance returned by [`useRouter()`](../reference/runtime-api#userouter). To listen for route changes, assign handlers on the router:
```ts [.vitepress/theme/index.ts]

Loading…
Cancel
Save