element中el-table表頭通過header-row-style設(shè)置樣式
一、知識點(diǎn)
有些時(shí)候需要給element-ui
表頭設(shè)置不同樣式,比如居中、背景色、字體大小等等,這時(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è)置某個(gè)表頭
<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;'; //藍(lán)色 } 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)生成一個(gè)多級嵌套菜單欄,這個(gè)方法應(yīng)用非常廣泛,需要的朋友可以參考下2018-06-06Vue2?中自定義圖片懶加載指令?v-lazy實(shí)例詳解
這篇文章主要為大家介紹了Vue2?中自定義圖片懶加載指令?v-lazy實(shí)例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-09-09Vue常見報(bào)錯(cuò)整理大全(從此報(bào)錯(cuò)不害怕)
寫代碼的過程中一定會遇到報(bào)錯(cuò),遇到報(bào)錯(cuò)不要擔(dān)心,認(rèn)真分析就可以解決報(bào)錯(cuò),同時(shí)積累經(jīng)驗(yàn),早日成為大牛,這篇文章主要給大家介紹了關(guān)于Vue常見報(bào)錯(cuò)整理的相關(guān)資料,需要的朋友可以參考下2022-08-08利用Vue Router實(shí)現(xiàn)單頁面應(yīng)用(SPA)的代碼示例
在當(dāng)今前端開發(fā)中,單頁面應(yīng)用(SPA)已成為一種主流的開發(fā)模式,它通過在用戶與網(wǎng)頁之間提供更流暢的交互體驗(yàn),來改變傳統(tǒng)多頁面應(yīng)用的思維,本文將詳細(xì)介紹如何利用 Vue.js 中的 Vue Router 來實(shí)現(xiàn)一個(gè)簡單的單頁面應(yīng)用,需要的朋友可以參考下2025-01-01setup+ref+reactive實(shí)現(xiàn)vue3響應(yīng)式功能
這篇文章介紹了通過setup+ref+reactive實(shí)現(xiàn)vue3響應(yīng)式功能,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-11-11