1.0.2 • Published 3 years ago
v-img-error v1.0.2
A simple Vue directive to catch img errors & broken links and replace them with default or custom fallback image. NO dependencies!
If you like this project, please give it a star & consider following the author. :)
Installation
npm install v-img-error
Install globally
main.js
import Vue from 'vue';
import vImgError from 'v-img-error';
Vue.use(vImgError)
Install locally
component.vue
import { vImgError as imgError } from "v-img-error";
export default {
directives: {
imgError
}
}
Basic Usage
<template>
<img src="myImg.png" v-img-error>
<img src="anotherImg.svg" v-img-error>
</template>
Advanced Usage
With your custom fallback Img:
<template> <img src="myImg.png" v-img-error="path/to/image"> <img src="anotherImg.svg" v-img-error="path/to/svg"> </template>
Authors
License
MIT © Maor Barel