常用组件 包括(第三方及个人封装)

常用组件:

数字滚动千分位逗号隔开

<template>
  <div class="vertical-num-scroll">
     <div v-for="(item, index) in numData" :key="index" class="real-time-num">
        <div v-if="!isNaN(item)" class="real-time-num-item" :style="{transform: `translateY(-${item*70}px)`}">
          <div>0</div>
          <div>1</div>
          <div>2</div>
          <div>3</div>
          <div>4</div>
          <div>5</div>
          <div>6</div>
          <div>7</div>
          <div>8</div>
          <div>9</div>
        </div>
        <div class="mark-item" v-else>
          <img src="@/assets/hw-h-report/d-red-icon.png" alt="" v-if="type==='red'">
          <img src="@/assets/hw-h-report/d-yellow-icon.png" alt="" v-if="type==='yellow'">
        </div>
      </div>
      <div class="up-arrow">
        <img :class="[{'up-icon': isUp}]" src="@/assets/hw-h-report/up-red.png" alt="" v-if="type==='red'">
        <img :class="[{'up-icon': isUp}]" src="@/assets/hw-h-report/up-yellow.png" alt="" v-if="type==='yellow'">
      </div>
  </div>
</template>
<script>
export default {
  name: 'scrollNum',
  props: {
    turnoverNum: {
      type: Number,
      default: 0
    },
    type: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      numData: []
    }
  },
  
  watch: {
    turnoverNum: {
      handler (n) {
        this.isUp = true
        this.handerData(n)
      },
      deep: true,
      immediate: true
    }
  },

  methods: {
    handerData (num) {
      let newNum = num + ''
      if (newNum.length <= 3) {
        newNum = newNum.slice(0, 3)
      // this.toOrderNum(num) // 递归添加"0"补位
      } else if ( 3 < newNum.length && newNum.length <= 6) {
        // window.console.log(num.length,num.slice(0, num.length - 3), num.slice(num.length - 3, num.length))
        newNum = newNum.slice(0, newNum.length - 3) + ',' + newNum.slice(newNum.length - 3, newNum.length)
      } else if (6 < newNum.length && newNum.length <= 9) {
        newNum = newNum.slice(0, newNum.length - 6) + ',' + newNum.slice(newNum.length - 6, newNum.length - 3) + ',' + newNum.slice(newNum.length - 3, newNum-length)
      } else if (9 < newNum.length && newNum.length <= 12) {
        newNum = newNum.slice(0, newNum.length - 9) + ',' + newNum.slice(newNum.length - 9, newNum.length - 6) + ',' + newNum.slice(newNum.length - 6, newNum.length - 3) + ',' + newNum.slice(newNum.length - 3, newNum-length)
      } else {
        this.$message.warning('数字过大,显示异常,请联系后台人员')
        return
      }
      window.console.log(newNum)
      this.numData = newNum.split('')
    },

    changeNum () {
      this.numData = [1,2,',',3,4,7]
    }
  }
}
</script>
<style lang="less" scoped>
@keyframes upArrow {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  50% {
    opacity: 0;
    transform: translateY(-100%);
  }
  75% {
    opacity: 0;
    transform: translateY(100%);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}
.vertical-num-scroll {
  display: flex;
  width: 100%;
  flex-direction: row;
  justify-content: flex-start;
  .real-time-num-item{
    // display: inline-block;
    transition: all 1s ease-out;
  }
  .real-time-num {
    display: inline-block;
    width: 31px;
    height: 70px;
    line-height: 90px;
    font-size: 51px;
    // margin-left: 3px;
    //line-height: 98px;
    text-align: center;
    overflow: hidden; // 隐藏内容
    position: relative;
    .mark-item {
      width: 31px;
      position: absolute;
      z-index: 1;
      bottom: -5px;
      right: 0;
      // img {
      //   width: ;
      // }
    }
  }
  .real-time-num{
    div {
      width: 35px;
      height: 70px;
      color: #ffffff;
      font-weight: bold;
      // font-family: Source Han Sans SC;
    } 
  }
  .up-arrow {
    margin-left: 8px;
    img {
      margin: 30px 0 0 4px;
    }
    .up-icon {
      animation: upArrow ease-in-out 1.5s;
      -webkit-animation: upArrow ease-in-out 1.5s; 
      -ms-animation: upArrow ease-in-out 1.5s; 
    }
  }
}
</style>

无缝滚动
vue-seamless-scroll
第三方文档:官方地址
示例demo

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值