vue-fall-back-image-directive
A Directive for setting fall back image in a vue js application.
Installation
- npm install
Run npm install --save vue-fall-back-image-directive
- With Modules
This Custom directive can be used globally or locally based on app use case.
Global usage
// ES6
// Inside main.js you can register directives globally
import Vue from "vue";
import ImageFallBack from "vue-fall-back-image-directive";
Vue.directive("image-fall-back", ImageFallBack);
Local usage
// ES6
import Vue from "vue";
import ImageFallBack from "vue-fall-back-image-directive";
// Inside App.vue or any other components add directives object
directives: {
ImageFallBack;
}
Usage
To use this plugin, simply add the v-image-fall-back
directive in img tag.
<img v-image-fall-back src="image url to load" /> <img v-image-fall-back="settings" src="image url to load" />