el-table el-table-column表頭嵌套循環(huán)數(shù)據(jù)的示例代碼
需求:

不同以前 現(xiàn)在需要表頭嵌套循環(huán) 以前只要
<template>
<el-table
:data="tableData"
style="width: 100%">
<el-table-column
prop="date"
label="日期"
width="180">
</el-table-column>
</el-table>
</template>
data() {
return {
tableData: [{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀區(qū)金沙江路 1518 弄'
}]
}
}現(xiàn)在需要表頭嵌套循環(huán):思路,兩個(gè)數(shù)組,一個(gè)數(shù)組循環(huán)表格數(shù)據(jù),一個(gè)循環(huán)表頭
<el-table
ref="pageTable"
:data="tableData"
style="margin-top: 15px"
height="548"
:header-cell-style="cellStyleFun"
id="out-table2"
>
<el-table-column
fixed
label="管轄單位"
prop="C_NAME"
:formatter="fmtTableProp"
align="center"
width="230"
>
<template slot-scope="scope">
<el-button
type="text"
style="white-space: pre-wrap"
@click="detailTree(scope.row)"
>{{ scope.row.C_NAME }}</el-button
>
</template>
</el-table-column>
<el-table-column
v-for="item in tableHeaderData" //單獨(dú)循環(huán)表頭-普通循環(huán)
:key="item"
:label="item"
align="center"
width="140"
>
<el-table-column
label="登錄次數(shù)"
prop="LOGIN_COUNT"
align="center"
width="140"
>
<template slot-scope="scope">
<span>{{ scope.row[item].LOGIN_COUNT }}</span>
</template>
</el-table-column>
<el-table-column
label="檢查次數(shù)"
prop="CHECK_COUNT"
align="center"
width="140"
>
<template slot-scope="scope">
<span>{{ scope.row[item].CHECK_COUNT }}</span>
</template>
</el-table-column>
</el-table-column>
</el-table>
js:
tableHeaderData: [], // 頭部列表數(shù)據(jù)
tableData: [], // 列表數(shù)據(jù)
searchFun() {
this.loading = true;
const param = this.paramSet();
workStatisticsByGx(param).then((data) => {
this.loading = false;
if (data.data && data.data.code == 10000) {
this.tableHeaderData = data.data.otherObj;//表頭時(shí)間
this.tableData = data.data.obj;//表格數(shù)據(jù)
} else {
this.$confirm(data.data.message || "服務(wù)器忙", "提示", {
type: "warning",
center: true,
customClass: "warn-dialog",
})
.then(() => {})
.catch(() => {});
}
});
},
到此這篇關(guān)于el-table el-table-column表頭嵌套循環(huán)數(shù)據(jù)的文章就介紹到這了,更多相關(guān)el-table el-table-column嵌套內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
記錄一下這些內(nèi)容只是以后查閱起來(lái)方便,作為自己知識(shí)積累的記錄。其中有很多是參考網(wǎng)絡(luò)上的資源,不再一一寫出出處,還請(qǐng)?jiān)髡咭娬彙?/div> 2010-12-12
JS在Chrome瀏覽器中showModalDialog函數(shù)返回值為undefined的解決方法
這篇文章主要介紹了JS在Chrome瀏覽器中showModalDialog函數(shù)返回值為undefined的解決方法,涉及javascript針對(duì)谷歌瀏覽器事件判定相關(guān)操作技巧,需要的朋友可以參考下2016-08-08
詳解bootstrap導(dǎo)航欄.nav與.navbar區(qū)別
本篇文章主要介紹了詳解bootstrap導(dǎo)航欄.nav與.navbar區(qū)別,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-11-11
IE6,IE7下js動(dòng)態(tài)加載圖片不顯示錯(cuò)誤
ie6,7下js動(dòng)態(tài)加載圖片不顯示錯(cuò)誤,碰到這類問題的朋友可以參考下。2010-07-07
鼠標(biāo)經(jīng)過(guò)顯示二級(jí)菜單js特效
本文章來(lái)給大家推薦一個(gè)不錯(cuò)的鼠標(biāo)經(jīng)過(guò)顯示二級(jí)菜單js特效效果,有需要了解的朋友可以參考一下2013-08-08
無(wú)constructor的class類還能new嗎問題解析
這篇文章主要為大家介紹了無(wú)constructor的class類是否還能new的問題解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-03-03
JavaScript通過(guò)Date-Mask將日期轉(zhuǎn)換成字符串的方法
這篇文章主要介紹了JavaScript通過(guò)Date-Mask將日期轉(zhuǎn)換成字符串的方法,涉及javascript日期、數(shù)組及字符串操作的相關(guān)技巧,需要的朋友可以參考下2015-06-06
echarts餅圖扇區(qū)添加點(diǎn)擊事件的實(shí)例
下面小編就為大家?guī)?lái)一篇echarts餅圖扇區(qū)添加點(diǎn)擊事件的實(shí)例。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-10-10最新評(píng)論

