当前位置: 首页 > news >正文

如何在 vue 渲染百万行数据,vxe-table 渲染百万行数据性能对比,超大量百万级表格渲染

vxe-table 渲染百万行数据性能对比,超大量百万级表格渲染;如何在 vue 渲染百万行数据;当在开发项目时,遇到需要流畅支持百万级数据的表格时, vxe-table 就可以非常合适了,不仅支持强大的功能,虚拟滚动渲染超大数据量也支持。

查看官网:https://vxetable.cn
gitbub:https://github.com/x-extends/vxe-table
gitee:https://gitee.com/x-extends/vxe-table

安装

 npm install vxe-table@4.12.2
// ...
import VxeUITable from 'vxe-table'
import 'vxe-table/lib/style.css'
// ...

createApp(App).use(VxeUITable).mount('#app')
// ...

效果

在这里插入图片描述

代码

<template>
  <div>
    <p>
      <vxe-button @click="loadList(5)">5行</vxe-button>
      <vxe-button @click="loadList(1000)">1k行</vxe-button>
      <vxe-button @click="loadList(10000)">1w行</vxe-button>
      <vxe-button @click="loadList(100000)">10w行</vxe-button>
      <vxe-button @click="loadList(500000)">50w行</vxe-button>
      <vxe-button @click="loadList(1000000)">100w行</vxe-button>
      <vxe-button @click="loadList(2000000)">200w行</vxe-button>
    </p>
    <vxe-grid ref="gridRef" v-bind="gridOptions"></vxe-grid>
  </div>
</template>

<script setup>
import { ref, reactive } from 'vue'
import { VxeUI } from 'vxe-table'

const gridRef = ref()

const gridOptions = reactive({
  border: true,
  showOverflow: true,
  height: 800,
  loading: false,
  columnConfig: {
    resizable: true
  },
  scrollY: {
    enabled: true,
    gt: 0
  },
  columns: [
    { type: 'checkbox', width: 60 },
    { type: 'seq', title: '序号', width: 100 },
    { field: 'name', title: 'Name', minWidth: 180 },
    { field: 'role', title: 'Role', width: 200 },
    { field: 'num', title: 'Num', width: 200 },
    { field: 'address', title: 'Address', width: 200 }
  ],
  data: []
})

// 模拟行数据
const loadList = (size = 200) => {
  gridOptions.loading = true
  setTimeout(() => {
    const dataList = []
    for (let i = 0; i < size; i++) {
      dataList.push({
        id: i,
        name: `名称${i} 名称名称 称`,
        role: `role ${i}`,
        num: 20,
        address: 'shenzhen shen'
      })
    }
    const $grid = gridRef.value
    if ($grid) {
      const startTime = Date.now()
      $grid.loadData(dataList).then(() => {
        VxeUI.modal.message({
          content: `加载时间 ${Date.now() - startTime} 毫秒`,
          status: 'success'
        })
        gridOptions.loading = false
      })
    }
  }, 350)
}

loadList(500)
</script>

https://gitee.com/x-extends/vxe-table

相关文章:

  • mapbox基础,加载popup弹出窗
  • Python+requests实现接口自动化测试框架
  • 【PyTorch】
  • 如何利用AI智能生成PPT提升工作效率
  • SD-WAN海外专线服务商选择指南
  • 泛目录程序——2025年AI多功能站群系统技术演进:无极架构的分布式智能与多模态
  • Vivado HLS 优化指令详解
  • 【Tauri2】005——tauri::command属性与invoke函数
  • 【C++篇】C++入门基础(二)
  • Web3.0合约安全:重入攻击防御方案
  • JavaScript 中Object.assign()和展开运算符在对象合并时的区别,各自的适用场景是什么?
  • Spring与Mybatis整合
  • DeepSeek(14):DeepSeek 模型微调
  • Go 语言标准库中sort模块详细功能介绍与示例
  • 为什么 PPO 概率计算适合连续动作
  • 办公网络健康监控(域名健康监控)
  • 六十天前端强化训练之第三十二天之Babel 转译配置大师级深度讲解
  • Python实现单因素方差分析
  • 构建大语言模型应用:简介(第一部分)
  • vs 2022安装指南
  • 网站建设管理制度/餐饮品牌全案策划
  • 做关键词排名卖网站/深圳网站关键词
  • 莆田网站建设创意/政府免费培训面点班
  • 商品交换电子商务网站开发/寻找客户的12种方法
  • 深圳网站建设深圳企业网站建设/汕头seo优化
  • 深圳网站建设公司fantodo/专门看广告的网站