首页 > 其他分享 >antd-design-vue的table中获取到其他列的数据,并添加样式

antd-design-vue的table中获取到其他列的数据,并添加样式

时间:2022-11-30 19:32:55浏览次数:45  
标签:vue price record design table customRender price2 priceType

获取其他列的数据
{
title: '价格(元)',
align: "center",
dataIndex: '',
scopedSlots: { customRender: 'price' },
// customRender: (text, record) => {
// if (record.priceType == '1') {
// return record.price;
// } else if (record.priceType == '2') {
// return record.price + " - " + record.price2;
// } else if (record.priceType == '3') {
// ...
// }
// }
},

若要添加样式

{
title: '价格(元)',
align: "center",
dataIndex: '',
scopedSlots: { customRender: 'price' }
},

在a-table中

<a-table
ref="table"
size="middle"
bordered
rowKey="id"
:columns="columns"
:dataSource="tableList"
:pagination="ipagination"
:loading="loading"
class="j-table-force-nowrap"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
@change="handleTableChange">

<span slot="price" slot-scope="text, record">
<span v-if="record.priceType == '1'">
<span>{{record.price}}</span>
</span>
<span v-if="record.priceType == '2'">
{{record.price}} - {{record.price2}}
</span>
<span v-if="record.priceType == '3'">
<span style="text-decoration:line-through">{{record.price}}</span>(原价)       {{record.price2}}(现价)
</span>
</span>

效果图:

标签:vue,price,record,design,table,customRender,price2,priceType
From: https://blog.51cto.com/u_12528551/5900334

相关文章