页面特效

Vue<页面进度加载效果>

2020-03-02  本文已影响0人  誰在花里胡哨
效果图:
plan_1.gif
代码如下:
<template>
  <div class="overall">
    <div class="box">
      <div class="text">
        <span
          class="num"
          :style="`background-image: linear-gradient(to top,#2de6cd 0%, #2de6cd ${num.plan}%, white ${num.plan}%, white 100%);`"
        >{{num.plan}}</span>%
      </div>
      <div class="line"  :style="`background-image: linear-gradient(to right,#6feedd 0%, #6feedd ${num.plan}%, white ${num.plan}%, white 100%);`"></div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      num: {
        plan: 0
      }
    };
  },
  mounted() {
    var timer = setInterval(() => {
      this.num.plan++;
      console.log(1);
      if (this.num.plan == 100) {
        clearInterval(timer);
      }
    }, 50);
  }
};
</script>

<style lang="scss" scoped>
.overall {
  background: #f0f0f0;
}
.text {
  color: #6feedd;
  font-size: 1.5rem;
  font-weight: bold;
  .num {
    display: inline-block;
    line-height: 73px;
    text-align: right;
    font-size: 6rem;
    font-weight: 100;
    color: transparent;
    /*淡入当前文本颜色的背景渐变*/
    // background-image: linear-gradient(to top,#50e62b 0%, #50e62b 80%, transparent 80%, transparent 100%);
    /*剪切到文本,把渐变从背景填充到文字当中*/
    -webkit-background-clip: text;
    background-clip: text;
  }
}
.line {
  width: 300px;
  height: 5px;
  margin-top: 2rem;
  box-shadow: 0 0 10px #6feedd;
}
</style>
上一篇 下一篇

猜你喜欢

热点阅读