美文网首页
element el-image error嵌套

element el-image error嵌套

作者: CRJ997 | 来源:发表于2020-03-09 12:43 被阅读0次

使用el-image进行图片显示的时候,如果不确定图片要使用哪个字段作为数据源(或者编写通用组件),可以用error slot进行嵌套。

<el-image :src="item.content" lazy fit="contain">
    <el-image fit="contain" slot="error" lazy :src="item.thumbnail"></el-image>
</el-image> <!--  两个字段都有可能存放图片的url -->

这样子当使用一个字段显示图片失败的时候,另一个字段会生效。

相关文章

网友评论

      本文标题:element el-image error嵌套

      本文链接:https://www.haomeiwen.com/subject/vltpdhtx.html