网上找了不少方法,都不行,可能是因为版本的问题,下面直接写成可以成功的方法吧:
给表格一个代表表头的类header-row-class-name
<el-table
ref="multipleTable"
:data="tableData"
border
tooltip-effect="dark"
style="width: 100%"
header-row-class-name="tableHeader"
@selection-change="handleSelectionChange"
>
<el-table-column
type="selection"
align="center"
label="全选"
width="70"
/>
</el-table>
再在类中定义样式,给了深度选择器::v-deep
才有效
<style lang="scss" scoped>
::v-deep .tableHeader th {
background-color: #aaaaaa;
color: #373838;
}