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

143
Visualizações
Issue with multiple custom events firing, second event not working in Vue

I am emitting two different custom events from child, and for some reason the second event doesn't work.

I have checked on the Vue console and both events are being fired, however, nothing happens for the second event. When I comment out the first one, the second works correctly, as if the first one was blocking the second one.

<child-component
 @upload="handleUpload"
 @uploading="mediaUploading"
/>

 methods: {
    handleUpload(response) { //doesn't work
      this.mediaLoading = false;
      console.log(this.mediaLoading);
    },

    mediaUploading() { //works
      this.mediaLoading = true;
    },
}

In child component

 this.$emit('uploading');
  try {
    data = await this.$api.get('/photo');
  } catch (e) {
    console.log(e)
  }
 this.$emit('upload', data);
       
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

i have pasted the code on my machine and both are working fine

parent

  <template>
  <child-component @upload="handleUpload" @uploading="mediaUploading" />
</template>

<script>
import childComponent from "./page4child.vue";
export default {
  components: {
    childComponent,
  },
  data() {
    return {
      mediaLoading: true,
    };
  },
  methods: {
    handleUpload(response) {
      //works
      this.mediaLoading = false;
      console.log(this.mediaLoading);
    },

    mediaUploading() {
      //works
      this.mediaLoading = true;
      console.log(this.mediaLoading);
    },
  },
};
</script>

Child

<template>
  <div>
    <button @click="trigger('item')">run</button>
  </div>
</template>

<script>
export default {
  methods: {
    async trigger(uploadedItem) {
      this.$emit("uploading");
      await new Promise((res) => {
        console.log("duck");
        res();
      });
      this.$emit("upload", uploadedItem);
    },
  },
};
</script>

enter image description here

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