Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

docs(plugins): add directive example #5667

Merged
merged 5 commits into from
Jul 6, 2022
Merged
Changes from 1 commit
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
Next Next commit
Add plugins directive example
Examples help people use directive
  • Loading branch information
HomWang authored Jun 30, 2022
commit ded64d10fa4cceb4ddb03c7f8bfcdc34a9ab2abc
15 changes: 15 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,19 @@ export default defineNuxtPlugin((nuxtApp) => {
})
```

### Use directive
atinux marked this conversation as resolved.
Show resolved Hide resolved

Then create a plugin file `plugins/directive.js`.

```ts
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.directive('focus', {
mounted(el) {
el.focus()
}
})
})
```


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