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

219
Vistas
Vue 3 event naming conventions confusing me

Inside my parent component, I have a child component:

<upsetting-moment-step
    :this-step-number="1"
    :current-step-number="currentStepNumber"
    @showNextStep="showNextStep"
></upsetting-moment-step>

My parent component also has this method:

methods: {
    showNextStep() {
        this.currentStepNumber++;
    }
},

I call this event from a button in my child component:

<button type="button" class="btn btn-lg btn-primary" @click="showNextStep">Continue</button>

Here is the child component method:

methods: {
    showNextStep() {
        this.$emit('showNextStep');
    }
},

Now this works great, but I'm confused, because it stops working when I use @show-next-step instead of @showNextStep in the child component tag.

According to the docs, it SHOULD work, and it is also the recommended way of doing it. However, it simply does not work.

What's funny, is if I change it to snake case, it works if I use this.$emit('show-next-step');. However, this is confusing me, because I'm able to pass my props via snake case, and use them in my component via camel case.

Am I doing something wrong?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

In your component upsetting-moment-step you are using an event with the name @showNextStep, @ - says it is an event. So, to run some action for the event you need to emit it first (The name must be the same as in the component. this.$emit('showNextStep'); to emit the event. Once you emit the event, up to your code, function showNextStep will run.

The naming convention is to write using camelCase for JS, and kebab-case for tags and events.

about 4 years ago · Juan Pablo Isaza Denunciar

0

The automatic case transformation of event names should work per documentation, as you described. However, there is a known bug (@vuejs/vue-next #2841) in versions 3.0.0 to 3.0.5.

The fix was released in 3.0.6, but you should probably update to the latest version (3.2.7 as of today).

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