vue2+vant+h5页面图片循环滚动效果

参考:插件vue-seamless-scroll的官网

实现效果:
在这里插入图片描述

1.下载插件

npm install vue-seamless-scroll --save
或者
yarn add vue-seamless-scroll

2.实现代码

<template>
  <div id="app">
    <vue-seamless-scroll
      :data="listData"
      :class-option="classOption"
      class="warp"
    >
      <div class="img-content">
        <div v-for="(item, index) in listData" :key="index" class="img-item">
          <img :src="item" alt=""/>
          <span>{{ index }}</span>
        </div>
      </div>
  </vue-seamless-scroll>

  </div>
</template>

<script>
import vueSeamlessScroll from "vue-seamless-scroll";
export default {
  name: 'App',
  components: {
    vueSeamlessScroll
  },
  data(){
    return {
        selectValue:'',
        listData: [
          'https://img01.yzcdn.cn/vant/apple-1.jpg',
          'https://img01.yzcdn.cn/vant/apple-2.jpg',
          'https://img01.yzcdn.cn/vant/apple-1.jpg',
          'https://img01.yzcdn.cn/vant/apple-2.jpg',
          'https://img01.yzcdn.cn/vant/apple-1.jpg',
          'https://img01.yzcdn.cn/vant/apple-2.jpg',
        ],

        classOption: {
          direction: 2,//滚动方向、0向下 1向上 2向左 3向右
          step: 0.5, // 数值越大速度滚动越快
          hoverStop: false, // 是否开启鼠标悬停stop
          // limitMoveNum: 3, // 开始无缝滚动的数据量 this.dataList.length
          // openWatch: true, // 开启数据实时监控刷新dom
          // singleHeight: 0, // 单步运动停止的高度(默认值0是无缝不停止的滚动) direction => 0/1
          // singleWidth: 0, // 单步运动停止的宽度(默认值0是无缝不停止的滚动) direction => 2/3
          // waitTime: 0, // 单步运动停止的时间(默认值1000ms)
        }
      
    }
  }
}
</script>
<style>
#app {
  margin-top: 60px;
}
.warp {
    width: 500px;
    height: 155px;
    margin: 0 auto;
    overflow: hidden;
    border: 2px solid #000;
  }
  .warp .img-content {
    display: flex;
  }
  .warp .img-item{
    width: 120px;
    margin-right: 20px;
    border:1px solid gray;
  }
  .warp .img-item img{
    width: 100px;
    height: 150px;
  }
</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值