Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
How to register custom directive in vue 3 <script setup>

I can't find this in the docs. There is only info on registering it global on the app

Is it possible to register a custom scoped directive with the <script setup>?

If I use regular script I have something like this:

<script>
import { defineComponent } from 'vue'
import { customDirective } from './customDirective';

export default defineComponent({
  directives: { customDirective }
})
</script>

Now with <script setup>:

<script setup>
// how to register this
import { customDirective } from './customDirective';
</script>

If I leave it like that, I get the error in the console

Failed to resolve directive

Any help is appreciated

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You need to resolve it with the v prefix.

<script setup>
import { customDirective as vCustomDirective } from './customDirective';
</script>

See the docs.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda