This article example shares the specific code of el-table to realize the merging of cells for your reference. The specific content is as follows el-table merge cells (vue+element) - First put in el-table: span-method="arraySpanMethod" <el-table :header-cell-style="{background:'#eef1f6',color:'#606266'}" :data="merchantList" border :span-method="arraySpanMethod"> <el-table-column align="center" prop="provinceName" label="Province"> </el-table-column> <el-table-column align="center" label="Agent Name"> <template scope="scope"> <span>{{scope.row.parentMerchantName == scope.row.merchantName ? '---' : scope.row.parentMerchantName}}</span> </template> </el-table-column> <el-table-column align="center" prop="cityName" label="市"> </el-table-column> <el-table-column align="center" prop="countryName" label="区"> </el-table-column> <el-table-column align="center" prop="merchantName" label="店铺"> </el-table-column> </el-table> Write the method in methods: //Merge cells arraySpanMethod ({ row, column, rowIndex, columnIndex }) { if (columnIndex === 0) {//Merge method for the first column, province const _row_1 = this.provinceArr[rowIndex]; const _col_1 = _row_1 > 0 ? 1 : 0; //If it is merged, _row=0, then this column needs to be cancelled return { rowspan: _row_1, colspan: _col_1 } } }, // Initialize merageInit () { this.provinceArr = [] this.provincePos = 0 }, //Method of merging arrays merge() { this.merageInit() for (var i = 0; i < this.merchantList.length; i++) { if (i === 0) { //The first line must exist this.provinceArr.push(1) this.provincePos = 0 } else { // Determine whether the current element is the same as the previous element this.provincePos is the serial number of the provinceArr content //province if (this.merchantList[i].provinceName === this.merchantList[i - 1].provinceName) { this.provinceArr[this.provincePos] += 1 this.provinceArr.push(0) } else { this.provinceArr.push(1) this.provincePos = i } } } }, Results: The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Knowledge about MySQL Memory storage engine
>>: The concept of MTR in MySQL
Introduction MySQL 5.7 aims to be the most secure...
Table of contents Solution: 1. IGNORE 2. REPLACE ...
For individual webmasters, how to make their websi...
We use the translate parameter to achieve movemen...
1. WebDesignerWall 2. Veerle's Blog 3. Tutori...
Today, I encountered a problem: the content in the...
A: Usually stored in the client. jwt, or JSON Web...
1. Create a repository in the specified directory...
Table of contents Overview 1. How to animate a DO...
Table of contents What is a trigger Create a trig...
There is an interview question that requires: a th...
0. Background Hardware: Xiaomi Notebook Air 13/In...
Table of contents 1. Implementation process 2. Di...
Table of contents 1. Related binlog configuration...
<br />Previous Web Design Tutorial: Web Desi...