安装插件:
npm install vue-seamless-scroll --save
引入插件:
//组价使用三步骤1、引入 2、注册 3、使用
import vueSeamlessScroll from 'vue-seamless-scroll' //1、引入
components: { //2、注册
vueSeamlessScroll
},
<vue-seamless-scroll></vue-seamless-scroll> //3、使用
//vue3 同上 代码多去少补
import { defineComponent } from "vue";
import { Vue3SeamlessScroll } from "vue3-seamless-scroll";
export default defineComponent({
components: {
Vue3SeamlessScroll
}
})
<vue3-seamless-scroll></vue3-seamless-scroll>
使用:
<template>
<div>
<vue-seamless-scroll v-if="settlementArr.length >= 1" :data="settlementArr" class="seamlessWarp" :class-option="defaultOption">
<ul class="finishLi">
<li v-for="(item, index) in settlementArr" :key='index'>
<p class="miaoshu">
{{item.changjing}}
</p>
</li>
</ul>
</vue-seamless-scroll>
</div>
</template>
<script>
import vueSeamlessScroll from 'vue-seamless-scroll'
export default {
data() {
return {
dataList: [],
}
},
components:{
vueSeamlessScroll
},
computed: {
defaultOption() {
return {
step: 0.4, // 数值越大速度滚动越快
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:6000, // 单步运动停止的时间(默认值1000ms)
}
}
},
}
</script>