Ant Design Vue表格插槽

columns中声明插槽别名,然后在html中进行使用

text:当前这个key使用时返回的对应值,

record:当前行数据,

index:下标

方法1

//html

<a-table bordered :columns="columns" :row-key="(record) => record.id" 
:data-source="loadData" size="middle">
      <span slot="no" slot-scope="text, record, index">{{ index + 1 }}</span>

      <span slot="renderToMB" slot-scope="text">{{ (text / 1024 / 1024).toFixed(2) }}                    
      </span>

      <span slot="action" slot-scope="text, record">
        <a-tooltip title="查看">
          <a-button icon="eye" @click="viewModel(record)" type="link" />
        </a-tooltip>
        <a-divider type="vertical" />
        <a-tooltip title="下载">
          <a-button icon="download" @click="download(record)" type="link" />
        </a-tooltip>
      </span>
    </a-table>


//js---data

columns: [
        {
          title: '序号',
          width: '50px',
          // align: 'center',
          scopedSlots: { customRender: 'no' },
        },
        {
          title: '名称',
          dataIndex: 'fileName',
        },
        {
          title: '类型',
          dataIndex: 'ext',
          // align: 'center',
          width: '100px',
        },
        {
          title: '操作',
          dataIndex: 'id',
          scopedSlots: { customRender: 'action' },
          // align: 'center',
          width: '100px',
        },
      ],

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值