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

479
Visualizações
nuxtjs vuejs @error is not firing in a component when trying to load a fallback image

I have a component that I feed with props.

When an image throws a 404 I want to load a fallback image. So far so good.

However the @error function never fires when an image is broken and I can't figure out why! I never get 'hello event' in the console.

The component is on the first level of a nuxt page, my setup is a static SPA.

I tried to implement it as mentioned at the end of this github issue: https://github.com/vuejs/vue/issues/5404

<template>
  <div class="channel">
     <div class="img">
       <img :src="imgUrl" :alt="name" :title="name" @error="getFallBackImage" />
     </div>
  </div>
</template>

<script>
  export default {
    data: function() {
      return {
        chanCover: this.cover
      }
    },
    props: {
      name: {
        type: String,
        required: true
      },
      cover: {
        type: String,
        required: true
      }
    },
    computed: {
      imgUrl() {
        console.log(this.chanCover)
        return "channels/"+this.chanCover+".jpg"
      },
    },
    methods: {
      getFallBackImage(event) {
        console.log("hello event")
        this.chanCover = "default"
      }
    }
  }
</script>

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