vue 에서 elment-ui table 은 상하 두 줄 의 같은 데이터 셀 을 합 칩 니 다.
3014 단어 vueElement-UI단원 격합치다
<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 이 상하 두 줄 의 똑 같은 데이터 셀 을 합 쳐 여러분 에 게 도움 이 되 기 를 바 랍 니 다.궁금 한 점 이 있 으 시 면 메 시 지 를 남 겨 주세요.편집장 은 신속하게 답 해 드 리 겠 습 니 다.여기 서도 저희 사이트 에 대한 여러분 의 지지 에 감 사 드 립 니 다!
만약 당신 이 본문 이 당신 에 게 도움 이 된다 고 생각한다 면,전 재 를 환영 합 니 다.번 거 로 우 시 겠 지만 출처 를 밝 혀 주 십시오.감사합니다!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Fastapi websocket 및 vue 3(Composition API)1부: FastAPI virtualenv 만들기(선택 사항) FastAPI 및 필요한 모든 것을 다음과 같이 설치하십시오. 생성main.py 파일 및 실행 - 브라우저에서 이 링크 열기http://127.0.0.1:...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.