Answer the question
In order to leave comments, you need to log in
Problem with v-if. How can I tell if an image has already been loaded? Why is the image reloading?
For lazy load pictures I use this
mouseEnterHandler () {
let img = new Image()
img.src = this.image
img.onload = () => {
this.show = true
}
}
v-if
. Pointing at this element with a picture, I insert it into the house and remove it back. But for some reason, once out of 50 such mouseovers, the picture is loaded again.
Answer the question
In order to leave comments, you need to log in
Perhaps the first request is of the OPTIONS type - the browser sends it to check the availability of the subsequent GET request from the server (the so-called preflight ). Perhaps you need to configure the server to send 204 and an empty response to these requests, a la:
if ($request_method = 'OPTIONS') {
return 204;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question