Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!