mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-31 07:40:33 +00:00
docs: explain how to set <NuxtLink>
defaults in nuxt config (#25610)
This commit is contained in:
parent
365eaba229
commit
541a802fef
@ -116,6 +116,34 @@ Defaults can be overwritten, see [overwriting defaults](#overwriting-defaults) i
|
|||||||
|
|
||||||
## Overwriting Defaults
|
## Overwriting Defaults
|
||||||
|
|
||||||
|
### In Nuxt Config
|
||||||
|
|
||||||
|
You can overwrite some `<NuxtLink>` defaults in your [`nuxt.config`](https://nuxt.com/docs/api/nuxt-config#defaults)
|
||||||
|
|
||||||
|
::callout{color="amber" icon="i-ph-warning-duotone"}
|
||||||
|
These options will likely be moved elsewhere in the future, such as into `app.config` or into the `app/` directory.
|
||||||
|
::
|
||||||
|
|
||||||
|
```ts [nuxt.config.ts]
|
||||||
|
export default defineNuxtConfig({
|
||||||
|
experimental: {
|
||||||
|
defaults: {
|
||||||
|
nuxtLink: {
|
||||||
|
// default values
|
||||||
|
componentName: 'NuxtLink',
|
||||||
|
externalRelAttribute: 'noopener noreferrer',
|
||||||
|
activeClass: 'router-link-active',
|
||||||
|
exactActiveClass: 'router-link-exact-active',
|
||||||
|
prefetchedClass: undefined, // can be any valid string class name
|
||||||
|
trailingSlash: undefined // can be 'append' or 'remove'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Custom Link Component
|
||||||
|
|
||||||
You can overwrite `<NuxtLink>` defaults by creating your own link component using `defineNuxtLink`.
|
You can overwrite `<NuxtLink>` defaults by creating your own link component using `defineNuxtLink`.
|
||||||
|
|
||||||
```js [components/MyNuxtLink.ts]
|
```js [components/MyNuxtLink.ts]
|
||||||
|
Loading…
Reference in New Issue
Block a user