vue-seamless-scroll 无缝滚动 使用方法

1、效果图

在这里插入图片描述

2、步骤

(1)引入插件

 import vueSeamless from 'vue-seamless-scroll'

(2)注册组件

  components: {vueSeamless},

(3)html使用



    <div  style=" height: 86%; padding:10px;margin: 0 auto;">
      <vue-seamless :data="dataList" :class-option="classOption" style=" height: 100%;overflow: hidden;">
        <div>
          <div v-for="item in dataList" >
            <div>
              <div style="width:50%;height: 100%;float: left;padding: 2px 5px;">
                <div style=" color: #00ffc6;">
                  <span>{{ item.optTime }}</span>
                </div>
              </div>
              <div style="width:20%;height: 100%;float: left;padding: 2px 5px;">
                <div style="color: #00ffc6;">
                  <span>{{ item.orgName }}</span>
                </div>
              </div>
              <div style="width:30%;height: 100%;float: left;padding: 2px 5px;">
                <div style="color: #00ffc6;">
                  <span>{{ item.optResult }}</span>
                </div>
              </div>
              <!--                        <div class="clear"></div>-->
            </div>
          </div>
        </div>
      </vue-seamless>
    </div>

(4)computed

// 监听属性 类似于data概念
        computed: {
            defaultOption () {
                return {
                    step: 0.5, // 数值越大速度滚动越快
                    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)
                }
            }
 
        },  

(5)data

dataList:[{optTime:'2021',orgName:'cdscd',optResult:'cdeeeeeeeeeeeeeee'},
      {optTime:'2021',orgName:'cdscd',optResult:'cdeeeeeeeeeeeeeee'},
      {optTime:'2021',orgName:'cdscd',optResult:'cdeeeeeeeeeeeeeee'},
      {optTime:'2021',orgName:'cdscd',optResult:'cdeeeeeeeeeeeeeee'},
      {optTime:'2021',orgName:'cdscd',optResult:'cdeeeeeeeeeeeeeee'},
      {optTime:'2021',orgName:'cdscd',optResult:'cdeeeeeeeeeeeeeee'}],

3、如果需要对滚动数据操作(实现点击方法)

@click=“handleClick($event)//使用这个方法即可,可加在需要加的地方

如果需要自定义传参

:data-id=“index” :data-index=“item.name”  //自定义要传参的内容

(1)html

 <div  style=" height: 86%; padding:10px;margin: 0 auto;"  @click="handleClick($event)">
                <vue-seamless :data="dataList" :class-option="classOption" style=" height: 100%;overflow: hidden;">
                  <div>
                    <div v-for="(item,i) in dataList" >
                      <div>
                        <div style="width:50%;height: 100%;float: left;padding: 2px 5px;">
                          <div style=" color: #00ffc6;">
                            <span :data-id="i" :data-index="item.optTime">{{ item.optTime }}</span>
                          </div>
                        </div>
                        <div style="width:20%;height: 100%;float: left;padding: 2px 5px;">
                          <div style="color: #00ffc6;">
                            <span>{{ item.orgName }}</span>
                          </div>
                        </div>
                        <div style="width:30%;height: 100%;float: left;padding: 2px 5px;">
                          <div style="color: #00ffc6;">
                            <span>{{ item.optResult }}</span>
                          </div>
                        </div>
                        <!--                        <div class="clear"></div>-->
                      </div>
                    </div>
                  </div>
                </vue-seamless>
              </div>

(2)methods

  handleClick(event){
      console.log(event)
      console.log(event.target)
      let id= event.target.dataset.id //自定义的内容必须用dataset获取到
      let name= event.target.dataset.index
      console.log(id)
      console.log(name)
    },
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值