G
G
GerHanNaN2021-05-12 13:49:22
Vue.js
GerHanNaN, 2021-05-12 13:49:22

Why doesn't the @error event fire in Vue?

The image is not on the page. The console writes
GET localhost:3000/portfolio/someDirection/topMob.jpg 404 (Not Found)

I insert the image itself like this

<img :src="imgSrc" @error="logError" alt="not work" />


Image path
imgSrc() {
            return `../someDirection/topMob.jpg`
  }


Function in @error

logError() {
            console.log("No image")
        }


Interestingly, if I insert a sign after the path into the line with the path before the image, then the directive works. For example:
imgSrc() {
            return `../someDirection/topMob.jpg  ломаю путь`
        }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question