vue實(shí)現(xiàn)無限消息無縫滾動(dòng)
本文實(shí)例為大家分享了vue實(shí)現(xiàn)無限消息無縫滾動(dòng)的具體代碼,供大家參考,具體內(nèi)容如下
一、html
<div class="table_box">
? ?<div class="table_title">
? ? <div class="table_title_item">告警時(shí)間</div>
? ? <div class="table_title_item">所屬集中器</div>
? ? <div class="table_title_item" style="width:40%">內(nèi)容</div>
? ?</div>
? ?<div class="table_content">
? ?<div :class="{anim:animate}" @mouseenter="Stop()" @mouseleave="Up()">
? ? <div class="table_item" v-for="(item, index) in chart4" :key="index">
? ? ?<div class="table_colum" :title="item.wtime">{{item.wtime}}</div>
? ? ?<div class="table_colum" :title="item.terminalName">{{item.terminalName}}</div>
? ? ?<div class="table_colum2" :title="item.remark">{{item.remark}}</div>
? ?</div>
? ?</div>
? ?</div>
</div>二、style
.table_box{
? ? padding:10px;
}
.table_title_item{
? ? width:30%;
? ? height:28px;
? ? color:#fff;
? ? color:#01C0C3;
? ? font-size: 14px;
? ? line-height: 28px;
? ? text-align: center;
}
.table_content{
? ? margin:5px;
? ? height:28vh;
? ? overflow: hidden;
}
.table_item{
? ? width:100%;
? ? // 設(shè)定行高
? ? height:30px;
? ? line-height: 30px;
? ? display: flex;
? ? color:#01C0C3;
? ? font-size:14px;
}
.anim{
? ? // 設(shè)定滾動(dòng)
? ? transition: all 0.5s;
? ? margin-top: -30px;//高度等于行高
}
.table_colum{
? ? width:30%;
? ? text-align: center;
? ? // 多出部分省略
? ? overflow: hidden;
? ? text-overflow: ellipsis;
? ? display: -webkit-box;
? ? -webkit-line-clamp: 1; //行數(shù)
? ? -webkit-box-orient: vertical;
}
.table_colum2{
? ? width:40%;
? ? text-align: center;
? ? // 多出部分省略
? ? overflow: hidden;
? ? text-overflow: ellipsis;
? ? display: -webkit-box;
? ? -webkit-line-clamp: 1; //行數(shù)
? ? -webkit-box-orient: vertical;
}三、js
<script>
export default {
? ? data() {
? ? ? ? return {
? ? ? ? ? ? // 告警滾動(dòng)部分
? ? ? ? ? ? chart4: [],
? ? ? ? ? ? animate: false,
? ? ? ? ? ? intNum: undefined
? ? ? ? }
? ? },
? ? created() {
? ? ? ? this.getAlarmDatas()
? ? },
? ? methods: {
? ? ? ? // 獲取報(bào)警數(shù)據(jù)
? ? ? ? getAlarmDatas() {
? ? ? ? ? ? getAlarmInfo().then(res => {
? ? ? ? ? ? ? ? if (res.code === 1 && res.data.length > 0) {
? ? ? ? ? ? ? ? ? ? this.chart4 = res.data
? ? ? ? ? ? ? ? ? ? this.ScrollUp()
? ? ? ? ? ? ? ? }
? ? ? ? ? ? })
? ? ? ? },
? ? ? ? /** 告警滾動(dòng)部分 */
? ? ? ? ScrollUp() {
? ? ? ? ? ? // 每次滾動(dòng)時(shí)先清除上次定時(shí)器
? ? ? ? ? ? this.Stop()
? ? ? ? ? ? let that = this
? ? ? ? ? ? this.intNum = setInterval(function() {
? ? ? ? ? ? ? ? that.animate = true // 向上滾動(dòng)的時(shí)候需要添加css3過渡動(dòng)畫
? ? ? ? ? ? ? ? setTimeout(() => {
? ? ? ? ? ? ? ? ? ? that.chart4.push(that.chart4[0]) // 將數(shù)組的第一個(gè)元素添加到數(shù)組的
? ? ? ? ? ? ? ? ? ? that.chart4.shift() // 刪除數(shù)組的第一個(gè)元素
? ? ? ? ? ? ? ? ? ? that.animate = false
? ? ? ? ? ? ? ? }, 500)
? ? ? ? ? ? }, 2000)
? ? ? ? },
? ? ? ? // 鼠標(biāo)移上去停止
? ? ? ? Stop() {
? ? ? ? ? ? clearInterval(this.intNum)
? ? ? ? },
? ? ? ? // 鼠標(biāo)移出
? ? ? ? Up() {
? ? ? ? ? ? this.ScrollUp()
? ? ? ? }
? ? }
}
</script>四、效果

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- vue條件渲染列表渲染原理示例詳解
- antd vue表格可編輯單元格以及求和實(shí)現(xiàn)方式
- vue3實(shí)現(xiàn)無縫滾動(dòng)組件的示例代碼
- vue實(shí)現(xiàn)無縫滾動(dòng)的示例詳解
- vue實(shí)現(xiàn)無縫滾動(dòng)手摸手教程
- vue實(shí)現(xiàn)消息向上無縫滾動(dòng)效果
- vue實(shí)現(xiàn)簡(jiǎn)單無縫滾動(dòng)效果
- vue實(shí)現(xiàn)列表無縫滾動(dòng)效果
- vue實(shí)現(xiàn)列表垂直無縫滾動(dòng)
- vue實(shí)現(xiàn)列表無縫滾動(dòng)
- el-table動(dòng)態(tài)渲染列、可編輯單元格、虛擬無縫滾動(dòng)的實(shí)現(xiàn)
相關(guān)文章
vue 3 中watch 和watchEffect 的新用法
本篇文章主要通過 Options API 和 Composition API 對(duì)比 watch 的使用方法,讓大家快速掌握 vue3 中 watch 新用法,需要的朋友可以參考一下哦,希望對(duì)大家有所幫助2021-11-11
富文本編輯器quill.js?開發(fā)之自定義插件示例詳解
這篇文章主要為大家介紹了富文本編輯器quill.js?開發(fā)之自定義插件示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-08-08
Vue Router動(dòng)態(tài)路由使用方法總結(jié)
這篇文章主要介紹了Vue Router動(dòng)態(tài)路由使用方法總結(jié),需要的朋友可以參考下2023-10-10
vue動(dòng)態(tài)綁定組件子父組件多表單驗(yàn)證功能的實(shí)現(xiàn)代碼
這篇文章主要介紹了vue動(dòng)態(tài)綁定組件子父組件多表單驗(yàn)證功能的實(shí)現(xiàn)代碼,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2018-05-05
從零開始搭建vue移動(dòng)端項(xiàng)目到上線的步驟
這篇文章主要介紹了從零開始搭建vue移動(dòng)端項(xiàng)目到上線的步驟,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-10-10
vue導(dǎo)出少量pdf文件實(shí)現(xiàn)示例詳解
這篇文章主要為大家介紹了vue導(dǎo)出少量pdf文件實(shí)現(xiàn)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-06-06

