当前位置: 首页> 科技> 名企 > 廊坊网站建设费用_2023年互联网创业项目_军事新闻头条_磁力库

廊坊网站建设费用_2023年互联网创业项目_军事新闻头条_磁力库

时间:2025/9/11 4:53:08来源:https://blog.csdn.net/m0_65730686/article/details/143578689 浏览次数:0次
廊坊网站建设费用_2023年互联网创业项目_军事新闻头条_磁力库

<template>
  <el-table :data="tableData" :span-method="arraySpanMethod" style="width: 100%">
    <el-table-column prop="id" label="ID" width="180"></el-table-column>
    <el-table-column prop="name" label="Name" width="180"></el-table-column>
    <!-- 其他列 -->
  </el-table>
</template>
 
<script>
import { ref } from 'vue';
 
export default {
  setup() {
    const tableData = ref([
      { id: 1, name: 'Alice' },
      { id: 1, name: 'Bob' },
      { id: 2, name: 'Charlie' },
      { id: 2, name: 'David' }
    ]);

 
    const idMap = new Map(); // 用于存储每个id连续出现的次数和起始行索引


    tableData.value.forEach((row, index) => {
      if (!idMap.has(row.id)) {
        idMap.set(row.id, { count: 1, startIndex: index });
      } else {
        const { count, startIndex } = idMap.get(row.id);
        idMap.set(row.id, { count: count + 1, startIndex });
      }
    });
 
    const arraySpanMethod = ({ row, column, rowIndex }) => {
      if (column.property === 'id') {
        const { count, startIndex } = idMap.get(row.id);
        if (rowIndex === startIndex) {
          return [count, 1]; // 在起始行,跨越count行,1列
        } else {
          return [0, 0]; // 其他行,不显示(被合并了)
        }
      } else {
        return [1, 1]; // 其他列,正常显示
      }
    };
 
    return {
      tableData,
      arraySpanMethod,
    };
  },
};
</script>

/*

//动态添加行或列 需要 在监听处清空map  idMap.clear();

watchEffect(() => {

  idMap.clear();

  tableData.value = final.value.list;

  tableData.value.forEach((row, index) => {

    let id = getpropertyId(row)

    if (!idMap.has(id)) {

      idMap.set(id, { count: 1, startIndex: index });

    } else {

      const { count, startIndex } = idMap.get(id);

      idMap.set(id, { count: count + 1, startIndex });

    }

  });

})

*/

关键字:廊坊网站建设费用_2023年互联网创业项目_军事新闻头条_磁力库

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: