<template>
...
<el-table-column v-for="(item, index) in tableHeaderArray" :key="index" :label="item" width="120" :prop="tableHeaderArray[index]">
<el-table-column align="center" label="早" />
<el-table-column align="center" label="中" />
<el-table-column align="center" label="晚" />
</el-table-column>
...
</template>
<script>
...
data() {
return {
tableHeaderArray: []
}
},
mounted (){
const currentDate = new Date();
const currentMonth = currentDate.getMonth();
this.tableHeaderArray = this.getEveryDay(currentMonth);
},
methods: {
getCountDays (m){
const currentDate = new Date();
currentDate.setMonth(m + 1);
currentDate.setDate(0);
return currentDate.getDate();
},
getEveryDay (m){
const dayArray = [];
const month = m +1;
const day = this.getCountDays(m);
for (let i = 1; i <= day; i++){
dayArray.push(month + "月" + i + "日");
}
return dayArray;
},
handleMonthChange (val){
this.tableHeaderArray = this.getEveryDay(val.getMonth());
}
}
...
</script>
vue根據(jù)選擇月份動(dòng)態(tài)設(shè)置表頭(Element-UI)
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 效果 將el-table和el-table-column獨(dú)立出來(lái)el-table封裝如下:MyTable.vue ...
- 項(xiàng)目中需求為實(shí)現(xiàn)一個(gè)列表,表頭動(dòng)態(tài)不固定,并且可能包含一級(jí)表頭以及二級(jí)表頭。 先上效果圖 實(shí)現(xiàn)思路: 首先表頭,包...
- 1、template <el-table :data="listData"...
- element-ui動(dòng)態(tài)生成表頭和數(shù)據(jù);應(yīng)用場(chǎng)景:由于業(yè)務(wù)需要根據(jù)后臺(tái)返回的數(shù)據(jù)進(jìn)行動(dòng)態(tài)的生成表格(表頭+數(shù)據(jù));...
- :default-active="$route.path.slice(1)" // 通過(guò)路徑自動(dòng)匹配導(dǎo)航(已截取...