vue竖屏滚动公告

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

vue竖屏滚动公告

张艳伟_Laura   2022-05-28 我要评论

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;
}

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们