Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/content/2.guide/3.directory-structure/11.plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,24 @@ export default defineNuxtPlugin((nuxtApp) => {
})
```

## Vue directives

Similarly, you can register a custom Vue directive in a plugin. For example, in `plugins/directive.ts`:

```ts
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.directive('focus', {
mounted (el) {
el.focus()
},
getSSRProps (binding, vnode) {
// you can provide SSR-specific props here
return {}
}
})
})
```

:ReadMore{link="https://vuejs.org/guide/reusability/custom-directives.html"}

Comment thread
danielroe marked this conversation as resolved.
:LinkExample{link="/examples/app/plugins"}