vue实现消息向上无缝滚动效果
复制代码
1
2
3
4
5<ul class="new-list" :class="{anim:animate}" @mouseenter="Stop()" @mouseleave="Up()"> <li v-for="item in noticeList"> ... </li> </ul>
复制代码
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<script> export default { data() { return { noticeList: [], animate:false, intNum: undefined, } }, created: function () { this.getNoticeData(); }, methods: { getNoticeData() { this.$http.get('/news/allList', { params: { 'pageNumber': 10, 'currentPage': 1 } }).then(res => { this.noticeList = res.data.items; this.ScrollUp(); }); }, ScrollUp() { this.intNum = setInterval(() => { this.animate=true;// 向上滚动的时候需要添加css3过渡动画 setTimeout(()=>{ this.noticeList.push(this.noticeList[0]);// 将数组的第一个元素添加到数组的 this.noticeList.shift(); //删除数组的第一个元素 this.animate=false; },500) }, 10000); }, //鼠标移上去停止 Stop() { clearInterval(this.intNum); }, Up() { this.ScrollUp(); }, } } </script>
样式
复制代码
1
2
3
4
5
6
7
8.new-list{ line-height: 28px; transition: top 0.5s; } .anim{ transition: all 0.5s; margin-top: -28px;//高度等于行高 }
转载于:https://www.cnblogs.com/conglvse/p/9988134.html
最后
以上就是眼睛大春天最近收集整理的关于Vue 消息无缝滚动的全部内容,更多相关Vue内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复