效果图:

注意效果图中,table的表格每一栏颜色都要不一样
代码实现:
页面结构:
<a-table :columns="columns" :loading="tableLoading" :data-source="tableData" rowKey='id' size="middle"
:rowClassName="rowClassName">
<template slot="operate" slot-scope="text, record">
<p class="detailP" @click="openModel(text, record)">详情 </p>
</template>
</a-table>
方法:
rowClassName(record, index) {
return index % 2 == 0 ? "first" : "second";
},
样式:
/deep/.ant-table-tbody .first {
background-color: #061236 !important;
}
/deep/.ant-table-tbody .second {
background-color: #071641 !important;
}
关键点:通过rowClassName这个属性去动态根据条件设置样式
本文介绍了如何在AntDesign的A-Table组件中,利用`rowClassName`属性根据索引动态为表格的每一栏设置不同的背景颜色。作者展示了如何使用JavaScript方法和CSS样式选择器来实现这一效果。
&spm=1001.2101.3001.5002&articleId=134779035&d=1&t=3&u=0d0441d10e3248ecba5d28b1841fda5d)
4090

被折叠的 条评论
为什么被折叠?



