vue 表格滚动

<template>
  <div class="table-wrapper">
    <div class="table-head">
      <table
        class="table-noborder"
        style="width:100%;table-layout: fixed"
        align="center"
      >
        <thead>
          <tr>
            <th width="25%">问题类型</th>
            <th width="35%">记录时间</th>
            <th width>状态</th>
          </tr>
        </thead>
      </table>
    </div>
    <div
      class="table-body"
      style="height: 100%;overflow: hidden;"
    >
      <table
        id="table-scroll"
        class="table-scroll table-noborder"
        style="top: 0px;table-layout: fixed"
        width="100%"
        cellspacing="0"
        cellpadding="0"
        align="center"
      >
        <tbody class="tbody">
<!--          <tr-->
<!--            v-for="(item,idx) in tableData"-->
<!--            :key="idx"-->
<!--          >-->
<!--            <td width="25%">{{item.type}}</td>-->
<!--            <td width="35%">{{item.created_at}}</td>-->
<!--            <td width>{{item.status_name}}</td>-->
<!--          </tr>-->
        <tr  v-for="i in 20" :key="i">
          <td>{{i}}</td>
          <td>30</td>
          <td>40</td>
        </tr>
        </tbody>
      </table>
    </div>
  </div>
</template>
 viewScroll () {
      let that = this;
      let $tbList = $("#table-scroll");
      let index = 0;
      let firstTr = $(".table-scroll tr:first").clone(); //复制第一个<tr>
      // $(".table-scroll tbody").append(firstTr);
      let scrollHeight = $(".table-scroll tr:first").height(); //获得当前<tr>的高度
      let len = $(".table-scroll tr").length;
      // return;
      // console.log(scrollHeight, "scrollHeight");
      this.scrollTimer = setInterval(function () {
        index++;
        scrollList();
      }, 1500);

      $tbList.hover(
        function () {
          clearInterval(that.scrollTimer);
        },
        function () {
          that.scrollTimer = setInterval(function () {
            index++;
            scrollList();
          }, 1500);
        }
      );

      //滚动动画
      function scrollList () {
        $tbList.stop().animate({ top: -scrollHeight }, 500, function () {
          $tbList
            .css({
              top: 0
            })
            .find("tr:first")
            .css({
              borderTop: 0
            })
            .appendTo($tbList);
        });
      }
    },


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

狗_都不做前端

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值