vue使用動(dòng)畫實(shí)現(xiàn)滾動(dòng)表格效果
本文實(shí)例為大家分享了vue使用動(dòng)畫實(shí)現(xiàn)滾動(dòng)表格效果的具體代碼,供大家參考,具體內(nèi)容如下
需求
在一些大屏項(xiàng)目中,需要使用到表格行數(shù)據(jù)滾動(dòng)。本文介紹在vue項(xiàng)目中使用動(dòng)畫實(shí)現(xiàn)滾動(dòng)表格。
vue代碼如下
<template> ? <div style="cursor: default;margin:9px 10px 18px"> ? ? <div class="table-header table-row"> ? ? ? <div class="table-cell" style="width: 25%">計(jì)劃名稱</div> ? ? ? <div class="table-cell" style="width: 40%">核心企業(yè)</div> ? ? ? <div class="table-cell" style="width: 15%">發(fā)行狀態(tài)</div> ? ? ? <div class="table-cell" style="width: 20%;text-align:right">金額(元)</div> ? ? </div> ? ? <div class="table-body"> ? ? ? <div :class="{ 'scroll-wrap': getPlayData.length > 0 }"> ? ? ? ? <div ? ? ? ? ? class="table-row" ? ? ? ? ? :class="{ hasBgc: index % 2 === 0 }" ? ? ? ? ? v-for="(item, index) in getPlayData" ? ? ? ? ? :key="index" ? ? ? ? ? :ref="'row_' + index" ? ? ? ? > ? ? ? ? ? <div class="table-cell" style="width: 25%" :title="item.productName"> ? ? ? ? ? ? {{ item.productName }} ? ? ? ? ? </div> ? ? ? ? ? <div class="table-cell" style="width: 40%" :title="item.coreName">{{ item.coreName }}</div> ? ? ? ? ? <div class="table-cell" style="width: 15%" :title="item.publish">{{ item.publish }}</div> ? ? ? ? ? <div class="table-cell" style="width: 20%;text-align:right" :title="item.publishAmount"> ? ? ? ? ? ? {{ item.publishAmount }} ? ? ? ? ? </div> ? ? ? ? </div> ? ? ? </div> ? ? </div> ? </div> </template> <script> export default { ? props: { ? ? data: { ? ? ? type: Array, ? ? ? default: () => { ? ? ? ? return []; ? ? ? }, ? ? }, ? }, ? data() { ? ? return { ? ? ? initMt: 0, ? ? ? // getPlayData:[], ? ? ? visible: true, ? ? ? stop: false, ? ? }; ? }, ? methods: { ? ? play() { ? ? ? const row = this.$refs["row_0"][0]; ? ? ? setTimeout(() => { ? ? ? ? this.visible = false; ? ? ? ? this.$nextTick(() => { ? ? ? ? ? this.initMt++; ? ? ? ? ? if (this.initMt === this.data.length) { ? ? ? ? ? ? this.initMt = 0; ? ? ? ? ? } ? ? ? ? ? this.visible = true; ? ? ? ? }); ? ? ? ? this.play(); ? ? ? }, 2000); ? ? }, ? }, ? watch: { ? }, ? computed: { ? ? getPlayData() { ? ? ? return this.data.concat(this.data.slice(0, 4)); ? ? }, ? }, ? mounted() { ? ? // this.play(); ? }, }; </script> <style lang="scss" scoped> $cellHeight: 35px; .table-row { ? display: flex; ? line-height: 35px; ? height: 35px; ? transition: all 0.3s; ? border-bottom: 1px solid rgba(63, 88, 114, 1); } .table-header { ? color: rgba(87, 150, 190, 1); } .table-cell { ? text-align: left; ? font-size: 12px; ? text-overflow: ellipsis; ? overflow: hidden; } // .hasBgc { // ? background: rgb(0, 59, 81); // } .hidden-row { ? height: 0 !important; ? line-height: 0 !important; ? display: none !important; } .table-body { ? height: 142px; ? overflow-y: hidden; ? .table-row { ? ? color: #fff; ? } } .scroll-wrap { ? animation: scroll 18s linear infinite; ? position: relative; } .scroll-wrap:hover { ? animation-play-state: paused; } @keyframes scroll { ? from { ? ? top: 0; ? } ? to { ? ? top: -8 * $cellHeight; ? } } </style>
通過(guò)動(dòng)畫動(dòng)態(tài)改變表格的位置來(lái)達(dá)到移動(dòng)的效果。把數(shù)據(jù)的一半拼接在原數(shù)據(jù)上作為滾動(dòng)數(shù)據(jù),達(dá)到銜接的效果。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
一篇文章告訴你Vue3指令是如何實(shí)現(xiàn)的
在計(jì)算機(jī)技術(shù)中,指令是由指令集架構(gòu)定義的單個(gè)的CPU操作,在更廣泛的意義上,“指令”可以是任何可執(zhí)行程序的元素的表述,例如字節(jié)碼,下面這篇文章主要給大家介紹了關(guān)于Vue3指令是如何實(shí)現(xiàn)的相關(guān)資料,需要的朋友可以參考下2022-01-01使用Vue動(dòng)態(tài)生成form表單的實(shí)例代碼
這篇文章主要介紹了使用Vue動(dòng)態(tài)生成form表單的實(shí)例代碼,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2018-04-04vue項(xiàng)目中實(shí)現(xiàn)全局引入jquery
這篇文章主要介紹了vue項(xiàng)目中實(shí)現(xiàn)全局引入jquery方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-06-06vue el-table 動(dòng)態(tài)添加行與刪除行的實(shí)現(xiàn)
這篇文章主要介紹了vue el-table 動(dòng)態(tài)添加行與刪除行的實(shí)現(xiàn)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-07-07vue 導(dǎo)航內(nèi)容設(shè)置選中狀態(tài)樣式的例子
今天小編就為大家分享一篇vue 導(dǎo)航內(nèi)容設(shè)置選中狀態(tài)樣式的例子,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-11-11vue 調(diào)用 RESTful風(fēng)格接口操作
這篇文章主要介紹了vue 調(diào)用 RESTful風(fēng)格接口操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-08-08