vue封装无限循环滚动表格

主要是以css控制滚动和暂停效果   animation-play-state: paused;

<!-- 轮播表组件 -->
<template>
    <div class="table-container">
      <div class="table-header">
        <!-- 固定表头 -->
        <div class="table-row">
          <div class="table-cell" v-for="(header, index) in swiperTitle" :key="index">
            {{ header }}
          </div>
        </div>
      </div>
      <div class="table-body">
        <!-- 无限循环滚动内容 -->
        <div class="table-scroll" id="tableScroll">
          <div v-for="(item, index) in swiperList" :key="item.id" class="table-row">
            <div class="table-cell">{{ item.areaName }}</div>
            <div class="table-cell">{{ item.shopName }}</div>
            <div class="table-cell">{{ item.count }}次</div>
          </div>
          <div v-for="(item, index) in swiperList" :key="item.id" class="table-row">
            <div class="table-cell">{{ item.areaName }}</div>
            <div class="table-cell">{{ item.shopName }}</div>
            <div class="table-cell">{{ item.count}}次</div>
          </div>
        </div>
      </div>
      
    </div>
  </template>
  
  <script>
  export default {
    props:{
        swiperList:[],
        swiperTitle:['辖区','商户','次数'],
        tableScrollTop:0
    },
    data() {
      return {
      };
    },
    methods: {
    },
    beforeDestroy() {
    },

  };
  </script>
  
  <style scoped lang="less">
 /deep/.el-button--mini{
    padding:5px 13px;
  }
  .table-container {
    overflow: hidden;
  }
  .table-body .table-row:nth-child(odd) {
  background-color: #143e9dbf;
}
  .table-row:hover{
    background-color: #08225c !important;
  }
  .table-header {
    background: #073aad;
}
  
  .table-header, .table-body {
    overflow-x: auto;
  }
  
  .table-row {
    display: flex;
    font-size: 14px;
  }
  .table-row>div:first-child {
    width: 20%;
    
}
.table-row>div:nth-child(2) {
    width: 50%;
}
.table-row>div:nth-child(3) {
    width: 30%;
}
  .table-cell {
    padding: 8px;
    text-align: center;
  }
  
  .table-scroll {
    animation: scroll 40s linear infinite; 
  }
  .table-scroll:hover {
      animation-play-state: paused; /* 鼠标移过去就暂停滚动,松开继续滚动 */
    }
  
  @keyframes scroll {
    0% {
      transform: translateY(0);
    }
    100% {
      transform: translateY(-50%);
    }
  }
  </style>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值