vue头部滚动公告栏

<template>
  <div class="textBox">
    <transition name="slide" v-if="this.list.rank">
      <p class="notice" :key="OnText.id">{{OnText.value}}</p>
    </transition>
  </div>
</template>
<script>
export default {
  data() {
    return {
      numbers: 0,
      list: {
        money: "",
        rank: [],
        rankCurrRank: ""
      }
    };
  },
  mounted() {
    this.loadDate();
    this.saveMove();
  },
  computed: {
    OnText() {
      let val = this.list.rank[this.numbers];
      return {
        id: this.numbers,
        value: val.nickname + "成功邀请了" + val.num + "好友"
      };
    }
  },
  methods: {
    loadDate() {
      this.getRequest("/share?token=" + token).then(data => {
        if (data.code == 200) {
          this.list = data.data;
        } else {
          alert(data.msg);
        }
      });
    },
    saveMove() {
      let time = setInterval(() => {
        if (this.list.rank.length > 0) {
          if (this.numbers === this.list.rank.length - 1) {
            this.numbers = 0;
          } else {
            this.numbers += 1;
          }
        }
      }, 2000);
    }
  }
};
</script>
<style lang="scss" scoped>
// 公告栏样式
.textBox {
  width: 100vw;
  height: 0.7rem;
  margin: 0 auto;
  overflow: hidden;
  position: absolute;
  top: 0;
  text-align: center;
  background: #0a0b0b;
  .notice {
    width: 100vw;
    padding: 0.23rem 0;
    font: normal 0.24rem MicrosoftYaHei;
    line-height: 0.25rem;
    letter-spacing: 0.014rem;
    color: #fbeece;
  }
  .slide-leave-active {
    transition: all 0.5s linear;
  }
  .slide-enter-active {
    transition: all 0.5s linear;
  }
  .slide-enter {
    transform: translateY(35px) scale(1);
    opacity: 1;
  }
  .slide-leave-to {
    transform: translateY(-35px) scale(1);
  }
}
</style>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值