当前位置:   article > 正文

vue3和vue2滚动列表页面_vue-seamless-scroll下载

vue-seamless-scroll下载

一、vue3和vue2滚动列表页面

1.下载插件

npm install vue3-seamless-scroll --save

2.引用

import { Vue3SeamlessScroll } from ‘vue3-seamless-scroll’

3.使用

//1
   <Vue3SeamlessScroll
          class="scroll"
          :list="list"
          :step="0.5"
        >
          <div
            v-for="(item,index) in list"
            :key="index"
            class="item"
          >
            <div
              class="name"
              :style="{color:item.color}"
            >
              {{ item.name }}
            </div>
            <div class="num">
              {{ item.num }}
            </div>
          </div>
        </Vue3SeamlessScroll>

//2
<script>
import { reactive, toRefs } from 'vue'
import { Vue3SeamlessScroll } from 'vue3-seamless-scroll'
export default {
  components: {
    Vue3SeamlessScroll
  },
  setup () {
    const state = reactive({
      list: [
        { name: '书店', num: '10', color: '#fff'},
        { name: '医院', num: '20', color: '#00' }
      ]
    })
    return {
      ...toRefs(state)
    }
  }
}
</script>

//3
.scroll{
  height: 80px;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49

二、vue2滚动列表页面

1.下载插件

npm installvue-seamless-scroll --save

2.引用

import vueSeamlessScroll from “vue-seamless-scroll”;

3.使用

//1
<vueSeamlessScroll
 :data="monitorStation" :class-option="option">
          <div v-for="(item, index) in monitorStation" :key="index">
            <div class="item item_type">{{ item.id }}</div>
            <div class="item item_endTime">{{ item.time }}</div>
            <div class="item item_duration">{{ item.state }}</div>
            <hr />
          </div>
          </div>
        </vueSeamlessScroll>

//2
<script>
import vueSeamlessScroll from "vue-seamless-scroll";

export default {
  components: {
    vueSeamlessScroll,
  },
  data() {
    return {
      monitorStation: [
        {
          id: 1,
          time: "2022",
          state: "预警",
        },
         {
          id: 2,
          time: "2021",
          state: "预警1",
        }
      ]
    };
  },
  computed: {
    option() {
      return {
        step: 0.3, // 数值越大速度滚动越快
        limitMoveNum: this.monitorStation.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)
      };
    },
  },
  //控制字数
  filters: {
    handleText(text) {
      if (text.length > 23) {
        return text.slice(0, 23) + "…";
      } else {
        return text;
      }
    },
  }
};
</script>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/煮酒与君饮/article/detail/998164
推荐阅读
相关标签
  

闽ICP备14008679号