You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

24 lines
455 B

export default (el, binding) => {
const { value } = binding
if (!value) return
imgSuccess(value)
.then(() => {
el.src = value
})
.catch(() => {
el.src = require('@/assets/images/nodata.svg')
})
}
function imgSuccess(url) {
return new Promise((resolve, reject) => {
const img = new Image()
img.src = url
img.onload = () => {
resolve(url)
}
img.onerror = () => {
reject(url)
}
})
}