共计 279 个字符,预计需要花费 1 分钟才能阅读完成。
//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".....
正文完
发表至: javascript
2021-03-29