Closed threetown closed 5 years ago
ScrollEnd回调无效
<template> <vue-seamless-scroll :data="listData" :class-option="classOption" @ScrollEnd="handleScrollEnd" class="seamless-warp"> <ul class="item"> <li v-for="item in listData"> <span class="title" v-text="item.title"></span> <span class="date" v-text="item.date"></span> </li> </ul> </vue-seamless-scroll> </template> <style lang="scss" scoped> .seamless-warp { height: 229px; color: #fff; overflow: hidden; } </style> <script> import vueSeamlessScroll from 'vue-seamless-scroll' export default { name: "scroll", components: { vueSeamlessScroll, }, data() { return { listData: [ { title: "无缝滚动第一行无缝滚动第一行", date: "2017-12-16" }, { title: "无缝滚动第二行无缝滚动第二行", date: "2017-12-16" }, { title: "无缝滚动第三行无缝滚动第三行", date: "2017-12-16" }, { title: "无缝滚动第四行无缝滚动第四行", date: "2017-12-16" }, { title: "无缝滚动第五行无缝滚动第五行", date: "2017-12-16" }, { title: "无缝滚动第六行无缝滚动第六行", date: "2017-12-16" }, { title: "无缝滚动第七行无缝滚动第七行", date: "2017-12-16" }, { title: "无缝滚动第八行无缝滚动第八行", date: "2017-12-16" }, { title: "无缝滚动第九行无缝滚动第九行", date: "2017-12-16" } ] }; }, methods: { handleScrollEnd(){ // console.clear() console.log('aabb') }, }, computed: { classOption () { return { step: 1, //数值越大速度滚动越快 // limitMoveNum: 5, //开始无缝滚动的数据量 //this.dataList.length hoverStop: true, //是否开启鼠标悬停stop direction: 1, // 0向下 1向上 2向左 3向右 openWatch: true, //开启数据实时监控刷新dom singleHeight: 41, //单步运动停止的高度(默认值0是无缝不停止的滚动) direction => 0/1 singleWidth: 0, //单步运动停止的宽度(默认值0是无缝不停止的滚动) direction => 2/3 waitTime: 5000 //单步运动停止的时间(默认值1000ms) } } }, }; </script>
已经解决了,直接把作者这个组件copy一份,然后自己加了几个$emit达到了想要的效果
$emit
源代码里的ScrollEnd是指所有数据滚动完一遍,可以根据需要自定义单步执行结束回调和等待一定时间后重新滚动的回调,不过需要改源代码
ScrollEnd回调无效