列表无限循环滚动,缩放页面不会卡主

该博客展示了如何使用vue-seamless-scroll插件在Vue.js应用中创建一个列表无限滚动的效果,并且在鼠标上移时能够暂停滚动。代码示例中,配置了插件参数以控制滚动速度、方向、数据监控等,并定义了列表项的样式。这个功能对于长列表的用户体验提升有显著作用。
摘要由CSDN通过智能技术生成

列表无限滚动利用vue-seamless-scroll 插件,鼠标上移停止滚动
在这里插入图片描述

<template>
            <section class="list-content"  v-else id="list-content">
                 <vue-seamless-scroll :data="data" class="seamless-warp" :class-option="classOption">
                        <div  v-for="item in data" :key="item.index" class="item"   @on-click="onClick"  @click="onClick(item)">
                            <div >{{item.contractName}}</div>
                            <div>{{item.percent}}</div>
                        </div>
                 </vue-seamless-scroll>
            </section>
</template>
<script>
import vueSeamlessScroll from 'vue-seamless-scroll'
export default {
  name: 'list',
  components: {
      vueSeamlessScroll
  },
  props:{
      data:{
          type: Array,
          default: () => []
      },
  },
  data(){ },
   computed: {
 classOption () {
    return {
        step: 2, // 数值越大速度滚动越快
        limitMoveNum: 2, // 开始无缝滚动的数据量 this.dataList.length
        hoverStop: true, // 是否开启鼠标悬停stop
        direction: 1, // 0向下 1向上 2向左 3向右
        openWatch: true, // 开启数据实时监控刷新dom
        singleHeight: 0, // 单步运动停止的高度(默认值0是无缝不停止的滚动) direction => 0/1
        singleWidth: 0, // 单步运动停止的宽度(默认值0是无缝不停止的滚动) direction => 2/3
        waitTime: 1000 // 单步运动停止的时间(默认值1000ms)
    }
 }
 },
}
</script>

<style lang="scss" scoped>
    .list{
        padding: 20px;
        display: flex;
        flex-direction: column;
        height: 100%;
    }
   
    .list-content{
        height: calc(100% - 38px);
        overflow: hidden;
    }
    .item{
        display: flex;
        border-bottom: 1px solid #4AFFF5;
        color: #fff;
        font-size: 14px;
        color: #fff;
        line-height: 38px;
        cursor: pointer;
        div{
            flex: 1;
            white-space: nowrap;
            width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            &:first-child{
                flex: 1.5;
            }
            &:nth-child(2){
                text-align: center;
            }
            &:nth-child(3){
                text-align: center;
            }
        }
    }
</style>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

蓝with黑

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

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

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

打赏作者

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

抵扣说明:

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

余额充值