element中el-table表頭通過header-row-style設(shè)置樣式
一、知識點
有些時候需要給element-ui
表頭設(shè)置不同樣式,比如居中、背景色、字體大小等等,這時就可以用到本文要說的屬性header-row-style
。官網(wǎng)說明如下所示:
二、設(shè)置全部表頭
2.1、方式一
<el-table :header-cell-style="{'text-align': 'center'}" />
2.2、方式二
<template> <el-table :header-cell-style="tableHeaderColor" /> </template> <script> export default { methods: { tableHeaderColor ({row, column, rowIndex, columnIndex}) { return 'text-align: center;' } } } </script>
三、設(shè)置某個表頭
<template> <el-table :header-cell-style="tableHeaderColor" /> </template> <script> export default { methods: { // 設(shè)置表頭的顏色 tableHeaderColor({ row, column, rowIndex, columnIndex }) { console.log(row, column, rowIndex, columnIndex); if (rowIndex === 0 && columnIndex === 1) { return 'background-color: #afccfd; color:#000000;'; //藍色 } else if (rowIndex === 0 && columnIndex === 2) { return 'background-color: #c0e33c; color:#000000;';//綠色 } else if (rowIndex === 0 && columnIndex === 3) { return 'background-color: #fbc57b; color:#000000;';//橙色 } else { return 'color:#000000; background: #ffffff;'; } } } } </script>
效果如下所示:
四、最后
到此這篇關(guān)于element中el-table表頭通過header-row-style設(shè)置樣式的文章就介紹到這了,更多相關(guān)element header-row-style設(shè)置樣式內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
vue2.0使用v-for循環(huán)制作多級嵌套菜單欄
這篇文章主要介紹了vue2.0制作多級嵌套菜單欄,主要使用v-for循環(huán)生成一個多級嵌套菜單欄,這個方法應(yīng)用非常廣泛,需要的朋友可以參考下2018-06-06利用Vue Router實現(xiàn)單頁面應(yīng)用(SPA)的代碼示例
在當(dāng)今前端開發(fā)中,單頁面應(yīng)用(SPA)已成為一種主流的開發(fā)模式,它通過在用戶與網(wǎng)頁之間提供更流暢的交互體驗,來改變傳統(tǒng)多頁面應(yīng)用的思維,本文將詳細介紹如何利用 Vue.js 中的 Vue Router 來實現(xiàn)一個簡單的單頁面應(yīng)用,需要的朋友可以參考下2025-01-01setup+ref+reactive實現(xiàn)vue3響應(yīng)式功能
這篇文章介紹了通過setup+ref+reactive實現(xiàn)vue3響應(yīng)式功能,文中通過示例代碼介紹的非常詳細。對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-11-11