vue實(shí)現(xiàn)豎屏滾動(dòng)公告效果
本文實(shí)例為大家分享了vue實(shí)現(xiàn)豎屏滾動(dòng)公告效果的具體代碼,供大家參考,具體內(nèi)容如下

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 }}晉級(jí)為{{ item.level }}
? ? ? ? ? ? </p>
? ? ? ? ? </div>
? ? ?</div>
</template>javascript文件
created(){
? ? this.getReportList();
? ? this.ScrollUp();
},
computed: {
? ? top() {
? ? ? return -this.activeIndex * 30 + "px";
? ? },
? },
?methods: { ??
? ?? ?//查詢晉級(jí)名單
? ? 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",
? ? ? ? ? ? });
? ? ? ? ? }
? ? ? ? });
? ? },
? ? //滾動(dòng)播報(bào)方法
? ? 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;
}以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
vue復(fù)雜表格單元格合并根據(jù)數(shù)據(jù)動(dòng)態(tài)合并方式
這篇文章主要介紹了vue復(fù)雜表格單元格合并根據(jù)數(shù)據(jù)動(dòng)態(tài)合并方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-02-02
基于vue-router的matched實(shí)現(xiàn)面包屑功能
本文主要介紹了基于vue-router的matched實(shí)現(xiàn)面包屑功能,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09
vue數(shù)據(jù)監(jiān)聽解析Object.defineProperty與Proxy區(qū)別
這篇文章主要為大家介紹了vue數(shù)據(jù)監(jiān)聽解析Object.defineProperty Proxy源碼示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-03-03
Vite創(chuàng)建項(xiàng)目的實(shí)現(xiàn)步驟
隨著 Vite2 的發(fā)布并日趨穩(wěn)定,現(xiàn)在越來越多的項(xiàng)目開始嘗試使用它。本文我們就介紹了Vite創(chuàng)建項(xiàng)目的實(shí)現(xiàn)步驟,感興趣的可以了解一下2021-07-07
vue跳轉(zhuǎn)同一個(gè)路由參數(shù)不同的問題
這篇文章主要介紹了vue跳轉(zhuǎn)同一個(gè)路由參數(shù)不同的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-08-08
Vue點(diǎn)擊在彈窗外部實(shí)現(xiàn)一鍵關(guān)閉的示例代碼
在Vue應(yīng)用中,彈窗是一個(gè)常見的交互元素,有時(shí)我們可能希望用戶點(diǎn)擊彈窗外部時(shí),彈窗能夠自動(dòng)關(guān)閉,本文主要介紹了Vue點(diǎn)擊在彈窗外部實(shí)現(xiàn)一鍵關(guān)閉的示例代碼,感興趣的可以了解一下2024-06-06

