//directive.js
export const imageerror = {inserted(dom, options) {
// debugger
dom.onerror = function() {dom.src = options.value}
}
}
ex....
main.js
import * as directives from '@directive'
Object.keys(directives).forEach(key => {Vue.directive(key, directives[key])
})
example
<img v-imageerror="defaultImg".....