Modifique o estilo element-ui em vue

1. Adicione id ou classe ao componente e, em seguida, adicione um estilo, não adicione escopo (o Vue pode ter vários estilos), modifique-o diretamente no componente 2.
Use profundidade::v-deep para modificar profundamente o estilo do componente , você pode escrevê-lo diretamente no estilo para o escopo do escopo

Exemplo: Modifique o fundo da tabela, etc.

<!-- 在element组件外加一层div,使其只在这个div内生效,防止改变全局 -->
<!-- 表头部分的样式需要利用组件提供的属性配合事件修改 -->
<div class="table-wrapper">
	<el-table id="out-table" v-loading="loading"
                 :cell-style="getRowClass"
                 :header-cell-style="getRowClass" :data="tableData" style="width: 100%;">
 </el-table>
</div>


methods:{

	// 修改element样式
            getRowClass({ row, column, rowIndex, columnIndex }) {
                return "background:transparent; border:none";
            }
}

//有scoped时,使用/deep/改变element样式
<style lang="less" scoped>
  //找到组件对应的类名利用deep修改样式
    .table-wrapper /deep/  .el-table, .el-table__expanded-cell {
        background-color: transparent;
    }

    .table-wrapper /deep/ .el-table tr {
        background-color: transparent!important;
    }
    .table-wrapper /deep/  .el-table--enable-row-transition .el-table__body td, .el-table .cell{
        background-color: transparent;
    }
    .table-wrapper /deep/  .el-table::before {
        height: 0;
    }
    .pager-box /deep/  .el-input__inner {
        background-color: transparent;
        color: #fff;
    }
</style>

//没有加spoced时,直接利用父级+所使用的组件类名修改即可
<style>
	.table-wrapper .el-table::before {
        height: 0;
    }
    .pager-box  .el-input__inner {
        background-color: transparent;
        color: #fff;
    }
</style>



Acho que você gosta

Origin blog.csdn.net/weixin_42215897/article/details/109808534
Recomendado
Clasificación