Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

181
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda