element 表格 去掉背景顏色
錯誤代碼:
發(fā)現(xiàn)這樣寫 表格并沒有去掉背景色
解決辦法
最后發(fā)現(xiàn)使用 ::v-deep
如果前面有其他類名 一定要有空格
?。?!文章來源:http://www.zghlxwxcb.cn/news/detail-529600.html
<div class="bkPart posPart t_btn2" style="width: 28%;">
<div class="co-title">缺料預警</div>
<el-table ref="table"
:header-cell-style="{backgroundColor: 'transparent',color: '#ffffff',fontSize: '9px',}"
:cell-style="{color: '#fff',backgroundColor: 'transparent',fontSize: '9px',}"
:row-style="{color: '#fff',backgroundColor: 'transparent',fontSize: '9px',}"
:data="maShortWarnData"
:default-sort="{ prop: '', order: '' }"
max-height="170px">
<template slot="empty">
<span style="color: #969799">{{ $t("NeoLight.empty") }}</span>
</template>
<el-table-column prop="line" label="名稱" width="120" align="center" />
<el-table-column prop="totalNeedCount" label="數(shù)量" width="50" align="center" />
<el-table-column prop="totalOutCount" label="累計發(fā)料" align="center" />
</el-table>
</div>
正確樣式代碼
// 由于是只在本頁面修改, 所以必須要用 /deep/ 或者 ::v-deep 才能生效 /deep/ 是深度選擇器,可自行百度了解更多
.t_btn2 ::v-deep.el-table,
.el-table__expanded-cell {
background-color: transparent !important;
}
.t_btn2 ::v-deep.el-table tr {
background-color: transparent !important;
}
.t_btn2 ::v-deep.el-table--enable-row-transition .el-table__body td,
.el-table .cell {
background-color: transparent !important;
}
.t_btn2 ::v-deep.el-table__row>td {
border: none !important;
}
.t_btn2 ::v-deep.el-table th.el-table__cell.is-leaf,
.el-table td.el-table__cell {
border-bottom: 1px solid #fff !important;
}
.t_btn2 ::v-deep.el-table td.el-table__cell {
border-bottom: 1px solid #fff !important;
}
.t_btn2 ::v-deep.el-table__empty-block {
background-color: transparent !important;
}
/* 清除底部橫線 */
.el-table::before {
height: 0px;
}
正確顯示效果
文章來源地址http://www.zghlxwxcb.cn/news/detail-529600.html
到了這里,關于使用::v-deep修改element組件自帶樣式 不生效【已解決】的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!