中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

臨平網(wǎng)站建設(shè)東莞專業(yè)網(wǎng)站推廣工具

臨平網(wǎng)站建設(shè),東莞專業(yè)網(wǎng)站推廣工具,wordpress頁面還原,四川建設(shè)人才培訓網(wǎng)站虛擬列表,實際上就是在首屏加載的時候,只加載可視區(qū)域內(nèi)需要的列表項,當滾動發(fā)生時,動態(tài)通過計算獲得可視區(qū)域內(nèi)的列表項,并將非可視區(qū)域內(nèi)存在的列表項刪除。該技術(shù)是解決渲染大量數(shù)據(jù)的一種解決方法。 實現(xiàn)虛擬列表&…

虛擬列表,實際上就是在首屏加載的時候,只加載可視區(qū)域內(nèi)需要的列表項,當滾動發(fā)生時,動態(tài)通過計算獲得可視區(qū)域內(nèi)的列表項,并將非可視區(qū)域內(nèi)存在的列表項刪除。該技術(shù)是解決渲染大量數(shù)據(jù)的一種解決方法。
實現(xiàn)虛擬列表,需要獲取以下幾個屬性

  1. 可視區(qū)域起始數(shù)據(jù)索引(startIndex)
  2. 可視區(qū)域結(jié)束數(shù)據(jù)索引(endIndex)
  3. 計算可視區(qū)域數(shù)據(jù),并渲染到頁面中
  4. 計算startIndex對應(yīng)的數(shù)據(jù)在整個列表中的偏移位置listTop并設(shè)置到列表上

高度固定

令A(yù)pp組件(父組件)產(chǎn)生一萬條虛擬數(shù)據(jù)來模擬接口,在List組件中實現(xiàn)對應(yīng)的功能

App組件:

<template><div><List :items="items" :size="60" :shownumber="10"></List></div>
</template><script>
import List from '@/List.vue'
export default {components: {List},computed: {// 模擬數(shù)據(jù)items() {return Array(10000).fill('').map((item, index) => ({id: index,content: index}))}}
};
</script><style scoped></style>

List組件:

<template><div class="container" :style="{ height: containerHeight }" @scroll="handleScroll" ref="container"><!-- 數(shù)據(jù)列表 --><div class="list" :style="{top:listTop}"><!-- 列表項 --><div v-for="item in showData" :key="item.id" :style="{height:size+'px'}">{{ item.content }}</div><!-- 用于撐開高度的元素 --><div class="bar" :style="{height:barHeight}"></div></div></div>
</template><script>
export default {name: 'List',props:{// 要渲染的數(shù)據(jù)items:{type:Array,required:true},// 每條數(shù)據(jù)渲染節(jié)點的高度size:{type:Number,required:true},// 每次渲染DOM節(jié)點個數(shù)shownumber:{type:Number,required:true}},data(){return{start:0,  //要展示數(shù)據(jù)的其實下標end:this.shownumber  //結(jié)束下標}},computed:{// 最終展示數(shù)據(jù)showData(){return this.items.slice(this.start,this.end)},// 容器的高度containerHeight(){return this.size * this.shownumber + 'px'},// 撐開容器內(nèi)部高度的元素的高度barHeight(){return this.size * this.items.length + 'px'},// 列表項上滾動改變top的值listTop(){return this.start * this.size + 'px'},},methods:{// 容器滾動事件handleScroll(){// 獲取容器頂部滾動的尺寸const scrollTop = this.$refs.container.scrollTopthis.start = Math.floor(scrollTop / this.size)this.end = this.start + this.shownumber}}
};
</script><style scoped>
.container{overflow-y: scroll;background-color: rgb(150,150,150,.5);font-size: 20px;font-weight: bold;line-height: 60px;width: 500px;margin: 0 auto;position: relative;text-align: center;
}
.list{position: absolute;top: 0;width: 100%;
}
</style>

這樣可以實現(xiàn)一個簡單的固定高度的虛擬列表功能。

http://www.risenshineclean.com/news/59173.html

相關(guān)文章:

  • seo網(wǎng)站開發(fā)注意事項鄭州整站網(wǎng)站優(yōu)化
  • 網(wǎng)站打不開顯示asp網(wǎng)站設(shè)計規(guī)劃
  • 做房地產(chǎn)資質(zhì)是什么網(wǎng)站查seo褲子的關(guān)鍵詞首頁排名有哪些
  • 建設(shè)公積金網(wǎng)站蘇州做網(wǎng)站的專業(yè)公司
  • 廣州市網(wǎng)站建設(shè)制作費用站長全網(wǎng)指數(shù)查詢
  • 2017自己做網(wǎng)站的趨勢seo站長
  • 學做網(wǎng)站網(wǎng)百度網(wǎng)訊科技有限公司官網(wǎng)
  • 長沙企業(yè)做網(wǎng)站百度一下你就知道官網(wǎng)網(wǎng)址
  • 如何制作香水 簡單seo交流論壇seo顧問
  • 網(wǎng)站維護步驟優(yōu)化營商環(huán)境存在問題及整改措施
  • 一元購網(wǎng)站建設(shè)多少錢seo自學教程seo免費教程
  • 河北seo推廣方案seo免費優(yōu)化網(wǎng)址軟件
  • 南充做網(wǎng)站公司哪家好營銷型網(wǎng)站推廣
  • 圖書館網(wǎng)站建設(shè)的建議免費信息推廣平臺
  • 企業(yè)做網(wǎng)站的發(fā)票怎樣入賬網(wǎng)頁設(shè)計框架圖
  • 醫(yī)院網(wǎng)站建設(shè) 價格網(wǎng)站免費搭建
  • 騰訊云服務(wù)器上傳網(wǎng)站b站視頻推廣網(wǎng)站2023
  • 光谷做網(wǎng)站推廣怎么樣百度模擬點擊軟件判刑了
  • 江西省建設(shè)監(jiān)督網(wǎng)站收錄
  • 動態(tài)網(wǎng)站開發(fā)常用技術(shù)龍網(wǎng)網(wǎng)絡(luò)推廣軟件
  • 在哪做網(wǎng)站便宜又好關(guān)鍵詞優(yōu)化步驟簡短
  • 廣州海珠發(fā)布seo排名軟件
  • 安裝wordpress報404錯誤網(wǎng)站seo專員
  • 蘇州做門戶網(wǎng)站的公司免費注冊推廣網(wǎng)站
  • 成都微信公眾號外包seo診斷工具有哪些
  • 自適應(yīng)網(wǎng)站平臺西安seo網(wǎng)絡(luò)推廣
  • 重慶建站管理系統(tǒng)信息seox
  • 海曙網(wǎng)站建設(shè)網(wǎng)站海南網(wǎng)站網(wǎng)絡(luò)推廣
  • 上海小企業(yè)網(wǎng)站建設(shè)資源企業(yè)網(wǎng)站排名優(yōu)化價格
  • 無錫高端網(wǎng)站設(shè)計制作白嫖永久服務(wù)器