【vue3】vue3-seamless-scroll无缝滚动列表的使用

使用版本:“vue3-seamless-scroll”: “^2.0.1”
下载:

npm install vue3-seamless-scroll --save

vue3-seamless-scroll

main.js全局配置(全局):

import App from './App.vue'
import { createApp } from 'vue'
import vue3SeamlessScroll from "vue3-seamless-scroll";
const app = createApp(App);
app.use(vue3SeamlessScroll);
app.mount('#app');

页面中使用:

<div class="rb-c">
          <div class="header">
            <div class="box-1"></div>
            <div class="box-2">标题内容</div>
            <div class="box-3">类型</div>
            <div class="box-4">发布时间</div>
          </div>
          <vue3-seamless-scroll class="seamless" :list="tableData" :limitScrollNum="5" :hover="true" :step="0.4" :wheel="true" :isWatch="true">
            <div class="msg" v-for="(item,index) in tableData" :key="index">
              <div class="box-1"><svg-icon name="dingwei"></svg-icon></div>
              <div class="box-2">{{item.name}}</div>
              <div class="box-3" :style="{color:item.type=='新闻'?'rgba(47,255,224,0.8)':'rgba(255,137,60,0.8)'}">{{item.type}}</div>
              <div class="box-4">{{item.content}}</div>
            </div>
          </vue3-seamless-scroll>
        </div>
const tableData= ref([])
onMounted(()=>{
   for (let i = 0; i < 50; i++) {
      tableData.value.push({
        type: i%2==1?"新闻":"成果",
        name: `文字内容标题信息文字内容标题信息`,
        content: new Date().toLocaleString()
      })
    }
})

.rb-c{
      position: relative;
      width: 100%;
      margin-top: 20px;
      height: 340px;
      overflow: hidden;
      pointer-events: auto;

      .seamless {
        width: 100%;
        height: 300px;
        overflow: hidden;
      }
      .header{
        position: relative;
        width: 100%;
        height: 40px;
        line-height: 40px;
        font-size: 20px;
        text-align: center;
        color: #1a98ff;
        font-weight: 600;
        background-color: #207adb61;
        display: flex;
      }
      .msg{
        position: relative;
        width: 100%;
        height: 60px;
        line-height: 60px;
        font-size: 18px;
        text-align: center;
        color: rgba(255, 255, 255, 0.8);
        background-color: #0a2f5761;
        display: flex;
      }
      .box-1{
        width: 10%;
      }
      .box-2{
        width: 35%;
        overflow:hidden;
        text-overflow:ellipsis;//文本溢出显示省略号
        white-space:nowrap;//文本不会换行
      }
      .box-3{
        width: 18%;
        overflow:hidden;
        text-overflow:ellipsis;//文本溢出显示省略号
        white-space:nowrap;//文本不会换行
      }
      .box-4{
        width: 35%;
        overflow:hidden;
        text-overflow:ellipsis;//文本溢出显示省略号
        white-space:nowrap;//文本不会换行
      }
    }

在这里插入图片描述

ps:表头多的也可直接使用网格布局(隔行换背景色)

<div class="header">
        <span v-for="(item,i) in  header" :key="i">
          {{item}}
        </span>
      </div>
      <vue3-seamless-scroll class="seamless" :list="showData" :limitScrollNum="6" :hover="true" :step="0.4"
                            :wheel="true" :isWatch="true">
        <div v-for="(item ,index) in showData" class="detail"
             :style="{'background-color':index%2===0?'transparent':'rgba(152,161,177,0.12)'}" :key="index">
          <span>{{ item.name }}</span>
          <span >{{ item.percent }}</span>
          <span >{{ item.num }}</span>
          <span>{{ item.date }}</span>
        </div>
      </vue3-seamless-scroll>
.header{
      line-height: 60px;
      font-size: 22px;
      color: #00D1FF;
      display: grid;
      grid-template-columns: 1fr .8fr .8fr .8fr ;
      text-align: center;
    }

    .seamless {
      position: relative;
      max-height: 340px;
      width: 100%;
      color: #fffc;
      background-color: transparent;
      overflow: hidden;
      text-align: center;
      pointer-events: auto;
    }

    .detail {
      display: grid;
      grid-template-columns: 1fr .8fr .8fr .8fr ;
      font-size: 20px;
      line-height: 45px;
      overflow: hidden;
      text-overflow: ellipsis; //文本溢出显示省略号
      white-space: nowrap; //文本不会换行
    }

在这里插入图片描述

  • 17
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值