本文实例为大家分享了Vue实现竖屏滚动公告效果的具体代码,供大家参考,具体内容如下 html文件 <template> <div class="scroll-wr
本文实例为大家分享了Vue实现竖屏滚动公告效果的具体代码,供大家参考,具体内容如下
html文件
<template>
<div class="scroll-wrap">
<div
class="scroll-content"
:style="{ top }"
@mouseenter="Stop()"
@mouseleave="Up()"
>
<p v-for="item in reportList">
恭喜{{ item.className }}{{ item.userName }}晋级为{{ item.level }}
</p>
</div>
</div>
</template>
javascript文件
created(){
this.getReportList();
this.ScrollUp();
},
computed: {
top() {
return -this.activeIndex * 30 + "px";
},
},
methods: {
//查询晋级名单
getReportList() {
var vm = this;
vm.$axiOS
.get("/personResult/selectImprovementList")
.then(function (response) {
if (response.data.code === "0000") {
vm.reportList = response.data.data;
} else if (response.data.code === "1111") {
vm.$message({
message: response.data.message,
type: "warning",
});
}
});
},
//滚动播报方法
ScrollUp() {
this.intnum = setInterval((_) => {
if (this.activeIndex < this.reportList.length) {
this.activeIndex += 1;
} else {
this.activeIndex = 0;
}
}, 1000);
},
Stop() {
clearInterval(this.intnum);
},
Up() {
this.ScrollUp();
},
}
css文件
.scroll-wrap {
position: relative;
z-index: 2;
float: left;
margin-left: 5%;
overflow: hidden;
}
.scroll-content {
position: relative;
transition: top 0.5s;
}
.scroll-content p {
line-height: 30px;
font-size: 20px;
color: yellow;
text-align: center;
}
--结束END--
本文标题: vue实现竖屏滚动公告效果
本文链接: https://lsjlt.com/news/145331.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-01-12
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0