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

天门市网站建设seo淘宝指数官网入口

天门市网站建设seo,淘宝指数官网入口,深圳市做网站的,做外贸的网站公司开篇 因最近工作中遇到了无分页情景下页面因大数据量卡顿的问题&#xff0c;在分别考虑并尝试了懒加载、虚拟滚动、分批渲染等各个方法后&#xff0c;最后决定使用分批渲染来解决该问题。 代码实现 表格代码 <el-table :data"currTableData"borderstyle"wi…

开篇

因最近工作中遇到了无分页情景下页面因大数据量卡顿的问题,在分别考虑并尝试了懒加载、虚拟滚动、分批渲染等各个方法后,最后决定使用分批渲染来解决该问题。

代码实现

表格代码

<el-table :data="currTableData"borderstyle="width: 100%;":max-height="getMaxHeight()":cell-style="CellStyle" @cell-click="handleCellClick"
><!--姓名列--><el-table-column style="background-color: #fff;":align="'center'"prop="userName"label="姓名"width="80"fixed/><!--工号--><el-table-column v-for="(item, index) in filteredCfgColumns":key="index"style="background-color: #fff;":align="'center'":prop="item.prop":label="item.label"/><!--这一块牵扯到合并列及周期模式切换后的动态展示需要特殊处理,不要写死--><el-table-column v-for="(date, index) in dateHeaders" :key="index" :align="'center'":class-name="isWeekend(date)":label-class-name="isWeekend(date)":width="getColumnWidth()"><!--星期几/日期--><template #header><div>{{ getWeekDay(date) }}</div><div>{{ parseDate(date) }}</div></template><!--表格内容 --><template #default="{row}"><div class="cell-content"v-if="row[date]":data-cell-content="JSON.stringify(row[date])":class="`${row[date].cellKey}`"><!-- 第一行 --><div v-if="pageSettingList.includes('显示附加班')" class="row"style="font-size: 8px;min-height: 12px; display: flex; align-items: center;"><el-row style="width: 100%;"><el-col :span="24" style="color: red;font-weight: 600;text-align: right;">{{ row[date]?.attchDetail || '' }}</el-col></el-row></div><!-- 第二行 --><div class="row"style="font-size: 10px;min-height: 20px; display: flex; align-items: center;white-space: nowrap;overflow: hidden;"><el-row style="width: 100%;"><el-col :span="24" style="font-weight: 600;text-align: center;"><StyledText :colorAndSchedules="colorAndSchedules":styledTexts="row[date]?.mainDetail || ''" /></el-col></el-row></div><!-- 第三行 --><div class="row"style="font-size: 8px;min-height: 12px; display: flex; align-items: center;"><el-row style="width: 100%;"><el-col :span="6" v-if="pageSettingList.includes('显示上期排班')"style="display: block;text-align: left;font-weight: 600;color: green;">{{ 'A1' }}</el-col><el-col :span="12" v-if="pageSettingList.includes('显示申请班')"style="display: block;text-align: center;font-weight: 600;color: green;">{{ row[date]?.applyDetail || '' }}</el-col><el-col :span="6" style="display: block;text-align: left;font-weight: 600;color: green;">  <div class="tip-con"><el-tooltipstyle="position: absolute!important; right: 0;bottom: 0; color: red; font-size: 12px;" placement="top" v-if="isShowRemark(row[date]?.remarkInfo)"><template #content><el-table :data="row[date]?.remarkInfo" style="width: 100%"><el-table-column prop="shifts" label="班次名" width="180" /><el-table-column prop="remark" label="备注" width="180" /><el-table-column prop="type" label="班次类型" /></el-table></template><el-icon><InfoFilled /></el-icon></el-tooltip></div></el-col></el-row></div>                                 </div></template></el-table-column>
</el-table>

分批渲染逻辑代码

  • 定义变量
 startIndex: 0, //开始索引,用于分批渲染的batchSize: 6, // 一次性渲染的条数
  • 分批渲染方法
const currTableData = ref([])const loadBatch = () => {if (state.startIndex < props.tableData.length) {const endIndex = Math.min(state.startIndex + state.batchSize, props.tableData.length);currTableData.value = currTableData.value.concat(props.tableData.slice(state.startIndex, endIndex));state.startIndex = endIndex;requestAnimationFrame(loadBatch);} 
}watch(() => props.tableData, newData => {currTableData.value = []; // 重置数据state.startIndex = 0;loadBatch()
}, { immediate: true })

效果

在这里插入图片描述在这里插入图片描述

上面便是分批渲染表格的具体实现方式,可以看到这个表格是相当复杂的,哪怕是使用了分批渲染,第一次也用了6秒多的时间,可想而知如果一次性渲染几百行几千行,消耗的时间肯定会大大影响用户体验。当然,这种页面性能的优化不仅仅分批渲染一种手段,后面我会持续探索,如果有了新的手段,也会总结成文的。
感谢阅读!

http://www.ds6.com.cn/news/41345.html

相关文章:

  • 政府网站建设四个定位最新疫情爆发
  • 做网站电话单页网站设计
  • 外网网址可以做英语阅读的网站seo实战教程
  • wordpress 转hexo专业seo网站优化推广排名教程
  • 找公司做网站的好处长沙好的seo外包公司
  • 河南企业网站建设价格360seo排名点击软件
  • 公司 网站 模板网站优化的方法有哪些
  • 开发电子商务网站和其他网站百度竞价培训
  • 东莞专业的单位网站建设百度推广如何代理加盟
  • 物联网网站的建设和维护网店运营推广实训
  • app简易开发平台seo关键字优化软件
  • 电商网站建设计划书企业网络营销推广平台
  • 网站测试毕设代做网络服务器多少钱一台
  • 网站建设合同 法律声明网站服务器信息查询
  • 山东青岛68元建网站竞价托管外包服务
  • 建立公司官网多少钱清远网站seo
  • 网站售后维护营销策划培训
  • 个人网站设计规划360网站收录提交入口
  • 做网站现在好弄么网络公司seo推广
  • 网站开发 混合式 数据库网络推广渠道排名
  • 大学生毕业设计网站南京seo域名
  • 新疆建设兵团第五师网站推广普通话手抄报
  • 网站建设推销拜访客户怎么开头seo链接优化建议
  • wordpress触屏主题网站怎样优化文章关键词
  • wordpress输网址采集太原百度seo排名
  • 怎样做网站图清晰百度云网盘下载
  • 学校网站模板 dedecms推销产品的万能句子
  • 怎么用dw做地图网站惠州百度seo地址
  • wordpress怎么远程保存图片大小网站seo标题优化技巧
  • 网站服务器 要求百度软件商店