I just started using Vue in the front-end of my website. In one of my Vue-components I want an image with a certain path:
<img src="path/example/with/vue/var">
Now, this is what I want to do:
- Check if the file in "path/example/with/vue/var" exists
- If not: Change the src to "another/path/with/vue/var"
- Check if "another/path/with/vue/var" exist
- If not: Change the src to "default/path"
I already tried to use onerror
with a function inside of it. But the problem is I'm loading 100+ objects with a couple of images for each object. If I just check if the file exists the normal way(through Ajax or with an XMLHttpRequest), the performance is completely gone. All objects are loaded through a JSON file.
I hope you guys understand the question.