docs: improve typing of default exports (#28520)

This commit is contained in:
Typed SIGTERM 2024-08-13 21:15:46 +08:00 committed by GitHub
parent 8c4a62b950
commit 3a42a7bc25
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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] ```ts [app/router.options.ts]
import type { RouterConfig } from '@nuxt/schema' import type { RouterConfig } from '@nuxt/schema'
export default <RouterConfig> { export default {
// https://router.vuejs.org/api/interfaces/routeroptions.html#routes // https://router.vuejs.org/api/interfaces/routeroptions.html#routes
routes: (_routes) => [ routes: (_routes) => [
{ {
@ -25,7 +25,7 @@ export default <RouterConfig> {
component: () => import('~/pages/home.vue').then(r => r.default || r) component: () => import('~/pages/home.vue').then(r => r.default || r)
} }
], ],
} } satisfies RouterConfig
``` ```
::note ::note
@ -90,8 +90,8 @@ This is the recommended way to specify [router options](/docs/api/nuxt-config#ro
```ts [app/router.options.ts] ```ts [app/router.options.ts]
import type { RouterConfig } from '@nuxt/schema' 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. 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 type { RouterConfig } from '@nuxt/schema'
import { createMemoryHistory } from 'vue-router' import { createMemoryHistory } from 'vue-router'
export default <RouterConfig> { export default {
// https://router.vuejs.org/api/interfaces/routeroptions.html // https://router.vuejs.org/api/interfaces/routeroptions.html
history: base => import.meta.client ? createMemoryHistory(base) : null /* default */ history: base => import.meta.client ? createMemoryHistory(base) : null /* default */
} } satisfies RouterConfig
``` ```