打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
vue

版权

效果图:

组件代码:

ProgressPlus.vue

<template>
  <div class="progress-plus" style="width: 100%">
    <div class="progress-box">
      <div class="gray" />
      <div class="colors" :style="setColor()" />
      <div class="icon icon1" />
      <div class="icon icon2" />
      <div class="icon icon3" />
      <div class="icon icon4" />
    </div>
    <span style="display: inline-block;padding-left: 5px" :style="{color:color}">{{ percent }}</span>
  </div>
</template>

<script>
export default {
  name: 'ProgressPlus',
  props: {
    color: {
      type: String,
      default: 'green'
    },
    percent: {
      type: Number,
      default: 0
    },
    width: {
      type: Number,
      default: 200
    }
  },
  methods: {
    setColor() {
      return {
        'background-color': this.color,
        'left': (this.percent - 100) + '%'
      }
    }
  }
}
</script>

<style scoped lang="scss">
.progress-plus{
  display: flex;
  &>span{
    width: 50px;
  }
  .progress-box{
    display: inline-block;
    position: relative;
    overflow: hidden;
    flex: 1;
    &>div{
      width: 100%;
      height: 10px;
    }
    .gray{
      background-color: gray;
    }
    .colors{
      /*background-color: green;*/
      position: absolute;
      top: 0;
      transition: left 1s;
    }

    .icon{
      position: absolute;
      width: 2px;
      bottom: 0;
      top: 0;
      background-color: #2d364b;
      &.icon1{
        left: 20%;
      }
      &.icon2{
        left: 40%;
      }
      &.icon3{
        left: 60%;
      }
      &.icon4{
        left: 80%;
      }
    }
  }
}
</style>

使用方法:

import ProgressPlus from './components/ProgressPlus'

components: { ProgressPlus }

<progress-plus style="width: 200px" :color="'#ff4941'" :percent="50" />

文章知识点与官方知识档案匹配,可进一步学习相关知识

显示推荐内容

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
一起学Vue自定义组件之进度条
相片+梅竹苑869 移动底标注
发烧、试音、完美的歌曲
vue.js实现用户评论、登录、注册、及修改信息功能
稳定灵活的 HTML 列式布局
vue瀑布流布局
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服