日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

el-table表格在表头和数据行添加图标、处理数据

發布時間:2025/3/12 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 el-table表格在表头和数据行添加图标、处理数据 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

通過header插槽自定義表頭:

<template slot="header" slot-scope="scope">... </template>

可以通過scope.row.columnName 獲取單元項數據進行數據處理:

<template slot-scope="scope"><span :class="1<2 ? 'red-font' : 'blue-font' ">{{formatDate(scope.row.temperature)}} ℃</span> </template>

如圖:

<el-table :data="currentCabinData"style="width: 100%" stripe border height="100"><el-table-column prop="name"label="設備倉" fixed></el-table-column><el-table-column prop="temperature" ><!-- 表頭項 --><template slot="header"slot-scope="scope"><span class="mgrinr1">溫度</span><d2-icon name="thermometer-2"style="font-size: 18px;" /></template><!-- 行數據項 --> <template slot-scope="scope">{{ scope.row.temperature }} <!-- scope.row.prop --> <span v-show="scope.row.temperature"class="unit-color">℃</span></template></el-table-column><el-table-column prop="humidity"><template slot="header"slot-scope="scope"><span class="mgrinr1">濕度</span><d2-icon name="tint"style="font-size: 18px;" /></template><template slot-scope="scope">{{ scope.row.humidity }}<span v-show="scope.row.humidity"class="unit-color">%</span></template></el-table-column></el-table>

上述el-table中關鍵字可以實現border縱向邊框、stripe斑馬線、固定表頭或表列、多級表頭、最小表高度、行單選、多選、數據過濾、展開行數據、樹形數據懶加載、自定義表頭、行尾統計、合并行或列等效果

?

?

使用header-cell-style屬性修改表頭樣式,可為函數或對象:

使用cell-style屬性更改表格中某個單元格的樣式,可為函數或對象:

<!-- html --> <el-table :header-cell-style="rowClass" :cell-style="cellStyle"> </el-table> //在method里面寫上方法 cellStyle({row, column, rowIndex, columnIndex}){if(rowIndex === 1 && columnIndex === 2){ //指定坐標return 'background:pink'}else{return ''} }

?

?

?

?

總結

以上是生活随笔為你收集整理的el-table表格在表头和数据行添加图标、处理数据的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。