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 can I import a directive in my vue app without using CLI

I am struggling to add a vue directive to my app that detects clicks outside of an element.

I installed it with npm and imported it in my scripttag like this:

import clickOutside from './node_modules/vue-detect-click-outside/index.js';

I then use it like this:

let app = Vue.createApp({
    // Data to work with
    data: function(){
        return{
            // Object to fill with JSON response
            results:[],
        }
    },
    mounted () {
        document.addEventListener("keyup", this.nextItem);
    },
    // Methods contains function that fire upon the (computed) data
    methods:{
        clickedOutside() {
            console.log("clicked outside");
        }
    }
})

app.mount('#v_search');

But I get: Failed to resolve directive: click-outside

I added the function on a button to test like this:

<button type="submit" @click.prevent="fetchResults" class="searchButton" v-click-outside="{
handler: 'clickedOutside',
exclude: ['excluded']
}">

What am I doing wrong? I didn’t use the CLI or anything to start a project. I built my project in jquery first and am now trying to convert it to Vue.

about 4 years ago · Juan Pablo Isaza
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!