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>
图片显示效果