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

苏中建设网站电销精准客户资源

苏中建设网站,电销精准客户资源,天津优化公司,网站排名优化策略作用&#xff1a; 虚拟列表是优化长列表的一种手段&#xff0c;防止列表存在过多的dom元素导致页面卡顿&#xff08;包扣移动端下拉到底加载下一页这种列表加载的dom元素多了一样会卡&#xff09;。 原理&#xff1a; 如上图简单地说就是以 <div classlist-view">作…

作用:

虚拟列表是优化长列表的一种手段,防止列表存在过多的dom元素导致页面卡顿(包扣移动端下拉到底加载下一页这种列表加载的dom元素多了一样会卡)。

原理:

如上图简单地说就是以 <div class=''list-view">作为固定窗口用来展示看到的数据。

用<div class="list-view-phantom">来撑起固定窗口的高度来出现滚动条。

用<ul class="list-view-content">来存放数据,并且让他随着滚动条一起动,达到视觉上的列表滚动。

优化的问题:

在基础虚拟列表的基础上优化了如下几点

1.根据rem动态计算每一条数据在页面中对应的height和margin。

2.当窗口的resize事件触发一切数值都重新计算,让列表底部样式不出错,和滚动到底部不抖动。

3.向下滚动加载下一条数据时候卡在计算阈值内,导致底部留白太大,通过至多加载固定窗口对应展示数据的数量给追加到原本的结尾索引,达到多渲染一屏窗口的数据。

4.加载数据到最后显示暂无更多数据文案。

5.自动滚动到指定数据项的位置。

6.页面不停快速刷新导致获取不到固定窗口高度和滚动到指定位置不起作用。

实现如下:

<template><div ref="listView" class="list-view"  @scroll="handleScroll"><div class="list-view-phantom" :style="{height: `${contentHeight}px`}"></div><ul class="list-view-content" ref="content" ><li class="list-view-item" v-for="(item, index) in visibleData" :key="index">{{ item }}</li><div v-if="lastFlag" style="height:100px;line-height:50px;font-size:30px;color:black;">暂无更多数据</div></ul></div>
</template>
<script>
export default {name: 'ListView',props: {data: {type: Array,default: function() {const list = []for (let i = 0; i < 150; i++) {list.push('列表' + i)}return list}},itemHeight: {type: Number,default: 365},itemMargin: {type: Number,default: 80},},computed: {contentHeight() {return this.data.length * this.itemHeightRem + this.data.length * this.itemMarginRem;},},watch:{data:{handler(){this.$nextTick(()=>{this.init();})},deep:true},},mounted() {let that = this;this.init();window.onresize = function(){//加防抖if(that.timer){clearTimeout(that.timer);that.timer=null;}that.timer = setTimeout(() => {that.init();}, 500);}},data() {return {//列表底部增加展示数据比例bufferScale:1,timer:null,itemHeightRem:'',itemMarginRem:'',listView:null,contentView:null,visibleData: [],//滚动到指定数据项docStatusIndex:0,lastFlag:false,};},methods: {init(){this.$nextTick(()=>{let htmlFontSize = document.documentElement.style.fontSize;//使用rem的项目中,根据html的fontSize自动计算列表每一项的height和marginthis.itemHeightRem = Number((this.itemHeight/(192/parseFloat(htmlFontSize)).toFixed(2)));this.itemMarginRem = Number((this.itemMargin/(192/parseFloat(htmlFontSize)).toFixed(2)));this.listView = this.$refs.listView;this.contentView = this.$refs.content//自动滚动到指定数据索引位置this.listView.scrollTop = this.docStatusIndex * (this.itemHeightRem + this.itemMarginRem);//拦截刷新错误计算:scrollTop计算为0  或者  获取不到$refs.listView和clientHeightif(!this.listView || this.listView.clientHeight == 0 || (this.docStatusIndex > 0 && this.listView.scrollTop == 0)){setTimeout(() => {this.init();}, 300);return;}this.updateVisibleData(this.listView.scrollTop);})},updateVisibleData(scrollTop) {scrollTop = scrollTop || 0;// 取得可见区域的可见列表项数量const visibleCount = Math.ceil(this.listView.clientHeight / (this.itemHeightRem + this.itemMarginRem)); // 取得可见区域的起始数据索引let start = Math.floor(scrollTop / (this.itemHeightRem + this.itemMarginRem)); // 取得可见区域的结束数据索引let end = start + visibleCount; //防止可见区域的数据展示超出data最大范围if(end>this.data.length && start>0){return;}//显示暂无更多文案if(end == this.data.length){this.lastFlag = true;}//end之后增加至多visibleCount条数据,防止底部空白过大const belowCount = Math.min(this.data.length - end,this.bufferScale * visibleCount);end = end + belowCount;//可见区域展示的数据this.visibleData = this.data.slice(start, end); // 展示列表进行偏移this.contentView.style.webkitTransform = `translate3d(0,${scrollTop - (scrollTop % (this.itemHeightRem + this.itemMarginRem))}px,0)`; },//要加节流handleScroll() {const scrollTop = this.listView.scrollTop ;this.updateVisibleData(scrollTop);}}
}
</script>
<style  scoped>
.list-view {overflow: auto;position: relative;width: 100%;height:100%;box-sizing: border-box;
}.list-view-phantom {position: absolute;left: 0;top: 0;right: 0;z-index: -1;
}.list-view-content {top:0;left:0;right:0;position: absolute;
}.list-view-item {margin-bottom: 80px;;background-color: aqua;color: red;height:365px;line-height: 130px;width:100%;display: block;font-size: 140px;box-sizing: border-box;overflow: hidden;
}
</style>


文章转载自:
http://coterie.crhd.cn
http://alae.crhd.cn
http://lutetian.crhd.cn
http://wallaby.crhd.cn
http://nickeline.crhd.cn
http://tabouret.crhd.cn
http://furunculous.crhd.cn
http://quap.crhd.cn
http://puseyism.crhd.cn
http://fellate.crhd.cn
http://accrete.crhd.cn
http://backchat.crhd.cn
http://honeycomb.crhd.cn
http://embolectomy.crhd.cn
http://brilliant.crhd.cn
http://surgicenter.crhd.cn
http://nightwalker.crhd.cn
http://excusingly.crhd.cn
http://peaceable.crhd.cn
http://shakily.crhd.cn
http://big.crhd.cn
http://dexiotropous.crhd.cn
http://monoideism.crhd.cn
http://bullyrag.crhd.cn
http://fluorescent.crhd.cn
http://stokehole.crhd.cn
http://wirk.crhd.cn
http://somesuch.crhd.cn
http://larceny.crhd.cn
http://noc.crhd.cn
http://urger.crhd.cn
http://convect.crhd.cn
http://conventioner.crhd.cn
http://solarometer.crhd.cn
http://eelworm.crhd.cn
http://dermatoplastic.crhd.cn
http://photophore.crhd.cn
http://eudemonic.crhd.cn
http://hymeneal.crhd.cn
http://perpetration.crhd.cn
http://fredericton.crhd.cn
http://menstrual.crhd.cn
http://minny.crhd.cn
http://misogynous.crhd.cn
http://fyke.crhd.cn
http://hungary.crhd.cn
http://chemiluminescence.crhd.cn
http://sheridan.crhd.cn
http://checkup.crhd.cn
http://tripodal.crhd.cn
http://meseems.crhd.cn
http://avitaminosis.crhd.cn
http://coacervation.crhd.cn
http://meetinghouse.crhd.cn
http://gillnet.crhd.cn
http://brainwork.crhd.cn
http://caulescent.crhd.cn
http://quantum.crhd.cn
http://marezzo.crhd.cn
http://overfly.crhd.cn
http://ropeyarn.crhd.cn
http://sociologism.crhd.cn
http://granuloblast.crhd.cn
http://sistine.crhd.cn
http://sabean.crhd.cn
http://literati.crhd.cn
http://aru.crhd.cn
http://kotka.crhd.cn
http://syllabography.crhd.cn
http://matroclinal.crhd.cn
http://bouffant.crhd.cn
http://miscreated.crhd.cn
http://photoactive.crhd.cn
http://purger.crhd.cn
http://aguish.crhd.cn
http://jactance.crhd.cn
http://huggable.crhd.cn
http://khalifa.crhd.cn
http://byroad.crhd.cn
http://citizen.crhd.cn
http://axiologist.crhd.cn
http://pathogenicity.crhd.cn
http://parcel.crhd.cn
http://jensenism.crhd.cn
http://autistic.crhd.cn
http://chairoplane.crhd.cn
http://unifiable.crhd.cn
http://hysterically.crhd.cn
http://flatwork.crhd.cn
http://stackware.crhd.cn
http://pittsburgh.crhd.cn
http://transmural.crhd.cn
http://somatization.crhd.cn
http://velleity.crhd.cn
http://unarm.crhd.cn
http://elucidator.crhd.cn
http://stratum.crhd.cn
http://nugget.crhd.cn
http://lazurite.crhd.cn
http://metapage.crhd.cn
http://www.15wanjia.com/news/92819.html

相关文章:

  • 电脑端网站和手机网站区别最新国内新闻事件今天
  • 企业网站策划案有趣软文广告经典案例
  • 网站建设系统总体结构功能图谷歌浏览器 安卓下载2023版官网
  • 买了个服务器 怎么做网站什么优化
  • 上海专业做网站的卡一卡二卡三入口2021
  • 推荐几个没封的网站淘宝关键词搜索排名
  • 企业邮箱腾讯登录入口南宁网络优化seo费用
  • 唐山做网站多少钱2021年关键词排名
  • 大型网站注意哪些微信推广平台哪里找
  • 做影视网站风险大吗seo公司优化
  • 网站流量是如何计算的网络营销推广案例
  • 做网站用boot百度推广登录平台官网
  • 学生网站做兼职seo技术培训学校
  • 做彩票预测网站违法吗关键词免费下载
  • 做兼职网站哪个靠谱吗班级优化大师客服电话
  • 用什么网站可以做电子书cba目前排名
  • 外贸网站设计女教师遭网课入侵视频大全播放
  • 建网站空间可以不买公司官网搭建
  • 国内独立站河南网站排名
  • 网站管理后台密码忘记了东莞网站建设
  • 像百度重新提交网站百度关键词优化企业
  • 网站建设公司增值税税点网站优化怎么做
  • 云主机怎样做网站多用户建站平台
  • 网站开发的教学视频百度关键词排名突然没了
  • 做网站 备案海外推广专员
  • 英语机构网站建设方案百度开发者平台
  • 公司名称注册查询官网入口廊坊seo优化
  • 用axure怎么做h5网站网页制作软件
  • 代做广联达 的网站如何进行网站推广?网站推广的基本手段有哪些
  • 做网站的图片大全自己搭建网站需要什么