1、cnpm 安装: 

cnpm install vue-seamless-scroll --save      (自行下载即可,也可使用npm)

2、引入

 在项目目录中,找到main.js。

import scroll from 'vue-seamless-scroll'
Vue.use(scroll)

普通引入方法:使用script标签

  <script src="vue.js"></script>
  <script src="vue-seamless-scroll"></script>

3、使用 (样式根据需求自行设置即可)

<vue-seamless-scroll :data="fourData" :class-option="classOption" class="warp">
            <ul id="scrollList">
              <li id="li1" v-for="(item,index) in fourData" :key="index">
                <span id="dataP2">{{item.createTime}}</span>
                <span id="weavingP2">{{item.barcode}}</span>
                <span id="inspectionP2">{{item.errmsg}}</span>
                <span id="failureP3">{{item.selfcheckOperation.workstation}}</span>
                <span id="failureP5">{{item.selfcheckOperation.userid}}</span>
                <span id="failureTwoP6">{{item.majorcheckOperation.workstation}}</span>
                <span id="failureTwoP7">{{item.majorcheckOperation.userid}}</span>
                <span id="failureThreeP8">{{item.mutualcheckOperation.workstation}}</span>
              </li>
            </ul>
  </vue-seamless-scroll>

配置默认值

computed: {
    classOption() {
      return {
        step: 0.3, //数值越大速度滚动越快
        limitMoveNum: 5, //开始无缝滚动的数据量  //this.fourDatata.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)
      };
    },
  },

效果如下

 

Logo

前往低代码交流专区

更多推荐