vue3-seamless-scroll 无缝滚动组件

本文介绍了如何在Vue3中使用vue3-seamless-scroll组件实现无缝滚动效果,包括组件的安装方式、全局和局部注册、使用示例以及详细的组件配置选项。
摘要由CSDN通过智能技术生成

Vue

1、vue3-seamless-scroll 无缝滚动组件

1、安装

  • npm安装

    • npm install vue3-seamless-scroll --save
      
  • Yarn 安装

    • yarn add vue3-seamless-scroll
      
  • browser 安装

    • <script src="https://unpkg.com/browse/vue3-seamless-scroll@1.0.2/dist/vue3-seamless-scroll.min.js"> </script>
      

2、使用

2.1 注册组件
  • 全局组件注册install

    • import vue3SeamlessScroll from 'vue3SeamlessScroll';
      app.use(vue3SeamlessScroll);
      
  • 单个.vue文件局部注册

    • <script>
        import { defineComponent } from "vue";
        import { Vue3SeamlessScroll } from "vue3-seamless-scroll";
         export default defineComponent({
            components: {
              Vue3SeamlessScroll
            }
         })
      </script>
      
      
2.2 使用组件
<template>
  <vue3-seamless-scroll :list="list" class="scroll">
    <div class="item" v-for="(item, index) in list" :key="index">
      <span>{{item.title}}</span>
      <span>{{item.date}}</span>
    </div>
  </vue3-seamless-scroll>
</template>
<script>
import { defineComponent, ref } from "vue";
import { Vue3SeamlessScroll } from "vue3-seamless-scroll";

export default defineComponent({
  name: "App",
  components: {
    Vue3SeamlessScroll
  },
  setup() {
    const list = ref([
      {
        title: "Vue3.0 无缝滚动组件展示数据第1条",
        date: Date.now(),
      },
      {
        title: "Vue3.0 无缝滚动组件展示数据第2条",
        date: Date.now(),
      },
      {
        title: "Vue3.0 无缝滚动组件展示数据第3条",
        date: Date.now(),
      },
      {
        title: "Vue3.0 无缝滚动组件展示数据第4条",
        date: Date.now(),
      },
      {
        title: "Vue3.0 无缝滚动组件展示数据第5条",
        date: Date.now(),
      },
      {
        title: "Vue3.0 无缝滚动组件展示数据第6条",
        date: Date.now(),
      },
      {
        title: "Vue3.0 无缝滚动组件展示数据第7条",
        date: Date.now(),
      },
      {
        title: "Vue3.0 无缝滚动组件展示数据第8条",
        date: Date.now(),
      },
      {
        title: "Vue3.0 无缝滚动组件展示数据第9条",
        date: Date.now(),
      },
    ]);
    return { list };
  },
});
</script>

<style>
.scroll {
  height: 270px;
  width: 500px;
  margin: 100px auto;
  overflow: hidden;
}

.scroll .item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 0;
}
</style>

3、组件配置
1234
keydescriptiondefaultval
step数值越大速度滚动越块1Number
limitMoveNum开启无缝滚动的数据量5Number
direction是否开启用鼠标hover控制trueBoolean
openTouch方向0往下 1向上 2 向左 3 向右1Number
singleHeight单步运动停止的高度(默认是0无缝不停止的滚动)direction=>0/10Number
waitTime单步停止等待的时间(默认值1000ms)1000Number
switchOffset左右切换按钮juice左右边界的边距(px)30Number
autoPlay1.1.17版本前手动切换时需要设置为falsetrueNumber
switchSingleStep手动单步切换step值(px)134Number
switchDelay单步切换的动画时间(ms)400Number
switchDisabledClass不可以点击状态的switch按钮父元素的类名disabledString
isSingleRemUnitsingleHeight and singleWidth是否开启rem度量falseBoolean
navigation左右方向的滚动是否显示控制器按钮,true的时候autoPlay自动变为falsefalseBoolean
  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值