在使用ant-design-vue设置斑马纹样式时,发现不能生效???
原因是下列代码报错
:row-class-name="(_record, index) => (index % 2 === 1 ? 'table-striped' : null)"
那只能换种方式改样式了:
<template>
<a-table :columns="columns" :data-source="data" @change="onChange" bordered />
</template>
我用的是scss代码,所以这里以scss代码演示
<style lang="scss" scoped>
:deep(.ant-table-tbody tr:nth-child(2n)) {
background-color: #fafafa;
}
</style>
使用deep选择器深度修改,使用方法为:
:deep(<修改的类名>)
可以哐哐改样式,那些element-ui组件的默认样式都能改(哇嘎嘎嘎)
附一张效果图: