vue 에서 elment-ui table 은 상하 두 줄 의 같은 데이터 셀 을 합 칩 니 다.

html :

 <el-table
 :header-cell-style="{background:'#6d7f93',color:'white'}"
 :data="ptableDate"
 align="center"
 border
 v-loading="loading"
 :height="tableHeight"
 :span-method="objectOneMethod"
 >
 <el-table-column align="center" show-overflow-tooltip prop="projName" ></el-table-column>
 <el-table-column align="center" show-overflow-tooltip prop="dirtySection" ></el-table-column>
 <el-table-column align="center" show-overflow-tooltip prop="towerNumber" ></el-table-column>
 <el-table-column align="center" show-overflow-tooltip prop="inclination" ></el-table-column>
 </el-table>
method

objectOneMethod({ row, column, rowIndex, columnIndex }) {
 if (columnIndex === 0) {
 const _row = this.setTable(this.ptableDate).one[rowIndex];
 const _col = _row > 0 ? 1 : 0;
 return {
 rowspan: _row,
 colspan: _col
 };
 }
 if (columnIndex === 1 ) {
 const _row = this.setTable(this.ptableDate).two[rowIndex];
 const _col = _row > 0 ? 1 : 0;
 return {
 rowspan: _row,
 colspan: _col
 };
 }
 },
 setTable(tableData) {
 let spanOneArr = [],
 spanTwoArr = [],
 concatOne = 0,
 concatTwo = 0;
 tableData.forEach((item, index) => {
 if (index === 0) {
 spanOneArr.push(1);
 spanTwoArr.push(1);
 } else {
 if (item.projName === tableData[index - 1].projName) {
 //               
 spanOneArr[concatOne] += 1;
 spanOneArr.push(0);
 } else {
 spanOneArr.push(1);
 concatOne = index;
 }
 if (item.dirtySection === tableData[index - 1].dirtySection) {
 //                
 spanTwoArr[concatTwo] += 1;
 spanTwoArr.push(0);
 } else {
 spanTwoArr.push(1);
 concatTwo = index;
 }
 }
 });
 return {
 one: spanOneArr,
 two: spanTwoArr
 };
 },
ps:ELEMENT-UI 셀 병합 방법 보기

arraySpanMethod({ row, column, rowIndex, columnIndex }) {
//        
  //columnIndex      
  //rowIndex      length % 3 ==0      
 if (columnIndex === 0) { //      
if (rowIndex % 3 === 0) {//         % 3 ==0
return {
rowspan: 3,
colspan: 1
};
} else {
return {
rowspan: 0,
colspan: 0
};
}
}
},

총결산
위 에서 말 한 것 은 편집장 이 소개 한 vue 에서 elment-ui table 이 상하 두 줄 의 똑 같은 데이터 셀 을 합 쳐 여러분 에 게 도움 이 되 기 를 바 랍 니 다.궁금 한 점 이 있 으 시 면 메 시 지 를 남 겨 주세요.편집장 은 신속하게 답 해 드 리 겠 습 니 다.여기 서도 저희 사이트 에 대한 여러분 의 지지 에 감 사 드 립 니 다!
만약 당신 이 본문 이 당신 에 게 도움 이 된다 고 생각한다 면,전 재 를 환영 합 니 다.번 거 로 우 시 겠 지만 출처 를 밝 혀 주 십시오.감사합니다!

좋은 웹페이지 즐겨찾기