docs: warn directives must be registered on both server/client (#22627)

This commit is contained in:
Daniel Roe 2023-08-14 22:28:55 +01:00 committed by GitHub
parent 4be2ffe4aa
commit 5492b0638f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -223,4 +223,8 @@ export default defineNuxtPlugin((nuxtApp) => {
}) })
``` ```
::alert{type=warning}
If you register a Vue directive, you _must_ register it on both client and server side unless you are only using it when rendering one side. If the directive only makes sense from a client side, you can always move it to `~/plugins/my-directive.client.ts` and provide a 'stub' directive for the server in `~/plugins/my-directive.server.ts`.
::
:ReadMore{link="https://vuejs.org/guide/reusability/custom-directives.html"} :ReadMore{link="https://vuejs.org/guide/reusability/custom-directives.html"}