vue實(shí)現(xiàn)消息向上無(wú)縫滾動(dòng)效果
本文實(shí)例為大家分享了vue實(shí)現(xiàn)消息向上無(wú)縫滾動(dòng)效果的具體代碼,供大家參考,具體內(nèi)容如下
代碼:
<ul class="new-list" :class="{anim:animate}" @mouseenter="Stop()" @mouseleave="Up()"> ? <li v-for="item in noticeList"> ? ? ... ? </li> </ul>
<script> ? export default { ? ? data() { ? ? ? return { ? ? ? ? noticeList: [], ? ? ? ? animate:false, ? ? ? ? intNum: undefined, ? ? ? } ? ? }, ? ? created: function () { ? ? ? this.getNoticeData(); ? ? }, ? ? methods: { ? ? ? getNoticeData() { ? ? ? ? this.$http.get('/news/allList', { ? ? ? ? ? params: { ? ? ? ? ? ? 'pageNumber': 10, ? ? ? ? ? ? 'currentPage': 1 ? ? ? ? ? } ? ? ? ? }).then(res => { ? ? ? ? ? this.noticeList = res.data.items; ? ? ? ? ? this.ScrollUp(); ? ? ? ? }); ? ? ? }, ? ? ? ScrollUp() { ? ? ? ? this.intNum = setInterval(() => { ? ? ? ? ? this.animate=true;// 向上滾動(dòng)的時(shí)候需要添加css3過(guò)渡動(dòng)畫 ? ? ? ? ? setTimeout(()=>{ ? ? ? ? ? ? this.noticeList.push(this.noticeList[0]);// 將數(shù)組的第一個(gè)元素添加到數(shù)組的 ? ? ? ? ? ? this.noticeList.shift(); //刪除數(shù)組的第一個(gè)元素 ? ? ? ? ? ? this.animate=false; ? ? ? ? ? },500) ? ? ? ? }, 10000); ? ? ? }, ? ? ? //鼠標(biāo)移上去停止 ? ? ? Stop() { ? ? ? ? clearInterval(this.intNum); ? ? ? }, ? ? ? Up() { ? ? ? ? this.ScrollUp(); ? ? ? }, ? ? } ? } </script>
樣式
.new-list{ ? ? line-height: 28px; ? ? transition: top 0.5s; } .anim{ ? ? transition: all 0.5s; ? ? margin-top: -28px;//高度等于行高 }
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- vue條件渲染列表渲染原理示例詳解
- antd vue表格可編輯單元格以及求和實(shí)現(xiàn)方式
- vue3實(shí)現(xiàn)無(wú)縫滾動(dòng)組件的示例代碼
- vue實(shí)現(xiàn)無(wú)縫滾動(dòng)的示例詳解
- vue實(shí)現(xiàn)無(wú)縫滾動(dòng)手摸手教程
- vue實(shí)現(xiàn)無(wú)限消息無(wú)縫滾動(dòng)
- vue實(shí)現(xiàn)簡(jiǎn)單無(wú)縫滾動(dòng)效果
- vue實(shí)現(xiàn)列表無(wú)縫滾動(dòng)效果
- vue實(shí)現(xiàn)列表垂直無(wú)縫滾動(dòng)
- vue實(shí)現(xiàn)列表無(wú)縫滾動(dòng)
- el-table動(dòng)態(tài)渲染列、可編輯單元格、虛擬無(wú)縫滾動(dòng)的實(shí)現(xiàn)
相關(guān)文章
Mint UI 基于 Vue.js 移動(dòng)端組件庫(kù)
Mint UI 包含豐富的 CSS 和 JS 組件,能夠滿足日常的移動(dòng)端開發(fā)需要。接下來(lái)通過(guò)本文給大家分享Mint UI 基于 Vue.js 移動(dòng)端組件庫(kù),需要的朋友參考下吧2017-11-11基于Vue設(shè)計(jì)實(shí)現(xiàn)一個(gè)彈幕組件
這篇文章主要給大家分享一個(gè)開發(fā)中常見的需求,接下來(lái)將為大家詳細(xì)介紹彈幕的實(shí)現(xiàn)以及設(shè)計(jì)思路一步一步描述出來(lái),希望大家能夠喜歡2023-06-06解決vue打包c(diǎn)ss文件中背景圖片的路徑問(wèn)題
今天小編就為大家分享一篇解決vue打包c(diǎn)ss文件中背景圖片的路徑問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-09-09vue+springboot實(shí)現(xiàn)登錄功能
這篇文章主要為大家詳細(xì)介紹了vue+springboot實(shí)現(xiàn)登錄功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-08-08Antd表格滾動(dòng) 寬度自適應(yīng) 不換行的實(shí)例
這篇文章主要介紹了Antd表格滾動(dòng) 寬度自適應(yīng) 不換行的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-10-10Vue實(shí)現(xiàn)單點(diǎn)登錄控件的完整代碼
這里提供一個(gè)Vue單點(diǎn)登錄的demo給大家參考,對(duì)Vue實(shí)現(xiàn)單點(diǎn)登錄控件的完整代碼感興趣的朋友跟隨小編一起看看吧2021-11-11