AntDesign vue学习笔记(六)Table 显示图片

AntDeign官网上没有table动态绑定显示图片的示例,baidu上搜索出来的大部分都是React语法,无法使用。

经过摸索,实现方法如下:以显示一个图片,一个按钮为例(picurl是返回的json数据,内容为图片地址)。


1、设置column,scopedslots

const columns = [
  { title: '图片',width: 120,dataIndex: 'picurl',fixed: 'left', key: 'pic',scopedSlots: { customRender: 'pic' }},
  { title: '操作', key: 'operation', fixed: 'right', width: 100, scopedSlots: { customRender: 'action' } }
]

2、设置table slot

<a-layout-content>
  <a-table :columns="columns" :dataSource="data" :rowSelection="rowSelection">
    <a slot="action" href="javascript:;">查看</a>
    <img  style="width:100px;heigth:100px" slot="pic" slot-scope="text, record" :src=record.picurl />
  </a-table>
</a-layout-content>

备注:img那行也可以写为

<img style="width:100px;heigth:100px" slot="pic" slot-scope="text" :src=text />

图片显示效果

 

 3、操作按钮会显示两列,解决办法:去掉fixed: 'right',或者加一个宽度,比如:fixed: 'right',width: 100即可。

转载于:https://www.cnblogs.com/zhaogaojian/p/11119762.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值