大屏滚动表格封装(VueSeamlessScroll)

 VueSeamlessScroll需要先npm安装,引入下面已经写了。修改上部分的标题和你的table数据字段即可。传列表的值给这个组件监听。监听到即可生成。

<template>
  <div class="table-box">
    <div class="t-head">
      <div class="th">标题1</div>
      <div class="th">标题2</div>
      <div class="th">标题3</div>
      <div class="th">标题4</div>
    </div>
    <div class="t-body">
      <VueSeamlessScroll :key="scrollKey" :vScaleY="'100%'" :data="data" :classOption="{ singleHeight: 39}" class="warp">
        <ul class="item">
          <li v-for="(item, index) in data" :key="index">
            <span class="td ell" :title="item.xx1">{{ item.xx1 }}</span>
            <span class="td ell" :title="item.xx2">{{ item.xx2 }}</span>
            <span class="td ell" :title="item.xx3">{{ item.xx3 }}</span>
            <span class="td ell" :title="item.xx4">{{item.xx4}}</span>
            <!--                  <span class="td">-->
            <!--                    <span v-if="item.zhuangtai===0" style="color:#28FF97;">状态1</span>-->
            <!--                    <span v-if="item.zhuangtai===1" style="color:#FFAF31;">状态2</span>-->
            <!--                  </span>-->
          </li>
        </ul>
      </VueSeamlessScroll>
    </div>
  </div>
</template>

<script>
import VueSeamlessScroll from 'vue-seamless-scroll'
export default {
  name: 'ClosedLoop',
  components: {
    VueSeamlessScroll
  },
  props: {
    TableData: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      scrollKey: 1,
      data: [],
      compressWidth: false
    }
  },
  watch: {
    TableData() {
      this.data = this.TableData
      this.scrollKey++
    }
  },
  created() {
    this.data = this.TableData
  },
  mounted() {

  },
  methods: {

  }
}

</script>
<style lang='scss' scoped>
.table-box{
  padding: 0 15px;
  .t-head{
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 5px;
    padding-top: 10px;
    .th{
      width: 25%;
      font-size: 11px;
      font-family: DOUYUFont;
      font-weight: 700;
      font-style: italic;
      color: #00E5ED;
      text-align: center;
      padding: 0 0;
    }
  }
  .t-body{
    height: calc(100% - 40px);
  }
  .warp{
    height: 100%;
    margin: 0 auto 0;
    overflow: hidden;
    ul {
      list-style: none;
      padding: 0;
      margin: 0 auto;
      li {
        position: relative;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 14px;
        cursor: pointer;
        height: 28px;
        background: transparent;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #ffffff;
        &:hover{
          //background-color: rgba(25, 101, 194, 0.74);
          .sanjiao{
            display: block;
          }
        }
      }
      li:nth-child(2n - 1){
        background: rgba(39, 104, 136, 0.3);
      }
      .td{
        display: block;
        width: 25%;
        padding: 0 8px;
        text-align: center;
      }
      .ell{
        white-space:nowrap;//不换行
        overflow: hidden;//超出隐藏
        text-overflow: ellipsis;//变成...
      }
    }

  }
}
</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值