docs: improve typing of default exports (#28520)

This commit is contained in:
Typed SIGTERM 2024-08-13 21:15:46 +08:00 committed by Daniel Roe
parent fe954c434c
commit cbeb97c7be
No known key found for this signature in database
GPG Key ID: CBC814C393D93268

View File

@ -16,7 +16,7 @@ If it returns `null` or `undefined`, Nuxt will fall back to the default routes (
```ts [app/router.options.ts]
import type { RouterConfig } from '@nuxt/schema'
export default <RouterConfig> {
export default {
// https://router.vuejs.org/api/interfaces/routeroptions.html#routes
routes: (_routes) => [
{
@ -25,7 +25,7 @@ export default <RouterConfig> {
component: () => import('~/pages/home.vue').then(r => r.default || r)
}
],
}
} satisfies RouterConfig
```
::note
@ -90,8 +90,8 @@ This is the recommended way to specify [router options](/docs/api/nuxt-config#ro
```ts [app/router.options.ts]
import type { RouterConfig } from '@nuxt/schema'
export default <RouterConfig> {
}
export default {
} satisfies RouterConfig
```
It is possible to add more router options files by adding files within the `pages:routerOptions` hook. Later items in the array override earlier ones.
@ -174,8 +174,8 @@ You can optionally override history mode using a function that accepts the base
import type { RouterConfig } from '@nuxt/schema'
import { createMemoryHistory } from 'vue-router'
export default <RouterConfig> {
export default {
// https://router.vuejs.org/api/interfaces/routeroptions.html
history: base => import.meta.client ? createMemoryHistory(base) : null /* default */
}
} satisfies RouterConfig
```