在我们项目中,假如遇到后台接口返回的图片不能显示,这样就很影响界面美观,下面是我的解决方案。
image.png解决方案:使用onerror,当时图片失效的时候触发
<template>
<img
src="images/logo.png"
:onerror="erroerImg"
style="width:100px;height:100px;"
>
</template>
<script>
data(){
return{
erroerImg:'this.src="'+require('@/assets/checar.jpg')+'"'
}
},
</script>
网友评论