js實(shí)現(xiàn)列表向上無(wú)限滾動(dòng)
更新時(shí)間:2020年01月13日 14:35:20 作者:除了奮斗別無(wú)選擇
這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)列表向上無(wú)限滾動(dòng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了js實(shí)現(xiàn)列表向上無(wú)限滾動(dòng)的具體代碼,供大家參考,具體內(nèi)容如下
先來(lái)一張效果圖
html
<div class="transdata1"> <ul class="tody-table-header2"> <li>商品</li> <li>數(shù)量(kg)</li> <li>單價(jià)(元)</li> <li>金額(元)</li> </ul> <div id="detetion-box2"> <div id="detetion-con1"> <ul v-for="(item,index) in todayDetetion2" :key="index"> <li>{{item.name}}</li> <li>{{item.amount}}kg</li> <li>{{item.price}}元/kg</li> <li style="color:rgba(0,255,204,1);">{{item.money}}元</li> </ul> </div> <div id="detetion-con2"></div> </div> </div>
js
getData() { var _this = this; this.$axios .get("請(qǐng)求的url") .then(res => { this.todayDetetion2 = res.data.data; this.$nextTick(() => { this.ScrollUp2(); }); }) .catch(err => {}); }, ScrollUp2() { var box = document.getElementById("detetion-box2"); var con1 = document.getElementById("detetion-con1"); var con2 = document.getElementById("detetion-con2"); this.speed = 50; if (con1.offsetHeight >= box.offsetHeight) { con2.innerHTML = con1.innerHTML; var timer1 = setInterval(scrol, this.speed); function scrol() { /*判斷滾動(dòng)內(nèi)容是否已經(jīng)滾完,滾完了則滾動(dòng)的值重新設(shè)置到0,否則就每個(gè)30默秒向上滾動(dòng)1px */ if (box.scrollTop >= con1.scrollHeight) { box.scrollTop = 0; } else { box.scrollTop++; } /*判斷滾動(dòng)的距離剛好為一條公告的高度時(shí)停掉定時(shí)器,隔1s之后重新啟動(dòng)計(jì)時(shí)器即可實(shí)現(xiàn)公告滾動(dòng)停留效果 */ if (box.scrollTop % 25 == 0) { clearInterval(timer1); setTimeout(() => { timer1 = setInterval(scrol, 30); }, 2000); } } } }
css(樣式自己調(diào))
.transdata1 { background: url("../../../static/img/transdata_bg.png") no-repeat center/100% 100%; height: 237px; padding: 36px 28px 16px 20px; box-sizing: border-box; transform: translateY(-12px); } .tody-table-header2 { overflow: hidden; } .tody-table-header2 li { height: 24px; width: 82px; line-height: 24px; list-style: none; float: left; font-size: 13px; margin-right: 48px; font-family: MicrosoftYaHei; color: rgba(127, 250, 255, 1); text-align: center; background: url("../../../static/img/thead_bg.png") no-repeat center/100%; background-size: 100% 100%; } .tody-table-header2 li:last-child { margin-right: 0; } #detetion-box2 { margin-top: 13px; height: 150px; overflow: hidden; } #detetion-box2 ul { overflow: hidden; border-bottom: 1px solid #0e579c; } #detetion-box2 li { width: 82px; height: 24px; line-height: 24px; float: left; margin-right: 48px; font-size: 12px; color: #fff; } #detetion-box2 ul li:last-child { margin-right: 0; }
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- Django 后臺(tái)帶有字典的列表數(shù)據(jù)與頁(yè)面js交互實(shí)例
- js、jquery實(shí)現(xiàn)列表模糊搜索功能過(guò)程解析
- js實(shí)現(xiàn)提交前對(duì)列表數(shù)據(jù)的增刪改查
- JS檢索下拉列表框中被選項(xiàng)目的索引號(hào)(selectedIndex)
- Vue.js 無(wú)限滾動(dòng)列表性能優(yōu)化方案
- vue.js基于v-for實(shí)現(xiàn)批量渲染 Json數(shù)組對(duì)象列表數(shù)據(jù)示例
- 原生JS實(shí)現(xiàn)列表內(nèi)容自動(dòng)向上滾動(dòng)效果
- 基于JavaScript實(shí)現(xiàn)控制下拉列表
相關(guān)文章
js獲取瀏覽器的可視區(qū)域尺寸的實(shí)現(xiàn)代碼
js獲取瀏覽器的可視區(qū)域尺寸的實(shí)現(xiàn)代碼,需要的朋友可以參考下。2011-11-11使用layer.msg 時(shí)間設(shè)置不起作用的解決方法
今天小編就為大家分享一篇使用layer.msg 時(shí)間設(shè)置不起作用的解決方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-09-09JavaScript實(shí)現(xiàn)圖片放大預(yù)覽效果
這篇文章主要介紹了JavaScript實(shí)現(xiàn)圖片放大預(yù)覽效果,幫助大家更好的理解和制作JavaScript特效,感興趣的朋友可以了解下2020-11-11js實(shí)現(xiàn)點(diǎn)擊向下展開的下拉菜單效果代碼
這篇文章主要介紹了js實(shí)現(xiàn)點(diǎn)擊向下展開的下拉菜單效果代碼,涉及javascript鼠標(biāo)事件控制頁(yè)面元素樣式變換的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-09-09使用FormData實(shí)現(xiàn)上傳多個(gè)文件
這篇文章主要為大家詳細(xì)介紹了使用FormData實(shí)現(xiàn)上傳多個(gè)文件功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-12-12