carousel 輪播自定義進度條

ThisCall發表於2024-03-12

<!-- Vue SFC -->
<template>
  <div class="propor-box">
    <div class="p20">
      <div>
        <el-carousel :interval="5000" arrow="always" height="250px">
          <el-carousel-item v-for="item in totalPages" :key="item">
            <div>
              <div v-for="(i, index) in carouselPageFn(item)" :key="index">
                <div class="flexba">
                  <span>{{ i.name }}</span>
                  <span>{{ i.count }}</span>
                </div>
                <div class="mb10">
                  <div class="base_information">
                    <div class="tixing">
                      <div
                        class="tixing_text tixing-back3"
                        :style="{
                          width: (i.count / 100) * 100 + '%',
                        }"
                      ></div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </el-carousel-item>
        </el-carousel>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  components: {},
  data () {
    return {
      FormData: {},
      baseList: [
        { name: '例項1', count: 50 },
        { name: '例項2', count: 10 },
        { name: '例項3', count: 90 },
        { name: '例項4', count: 40 },
        { name: '例項4', count: 40 },
        { name: '例項4', count: 40 },
        { name: '例項4', count: 40 },
        { name: '例項4', count: 40 },
        { name: '例項4', count: 40 },
        { name: '例項4', count: 40 },
        { name: '例項4', count: 40 },
        { name: '例項4', count: 20 },
        { name: '例項4', count: 10 },
      ],
      pageSize: 4,
      type: 1,
    };
  },
  created () { },
  mounted () { },

  computed: {
    totalPages () {
      return Math.ceil(this.baseList.length / this.pageSize);
    },
  },
  methods: {
    getData (row) {

      this.FormData = row;
      this.baseList = row.baseList;
    },
    carouselPageFn (page) {
      const start = (page - 1) * this.pageSize;
      const end = start + this.pageSize;
      return this.baseList.slice(start, end);
    },
  },
};
</script>
<style lang="scss" scoped>
.propor-box {
  box-sizing: border-box;
  // position: absolute;
  // bottom: 10px;
  // left: 0;
  width: 100%;
}
.icon_transform {
  transform: rotate(90deg);
}
.tabs_class {
  background-color: #484c6f;
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
}
.tabs_class1 {
  background-color: #484c6f;
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  margin-left: -12px;
}
.tabs_bgc {
  background-color: #0088fe;
  z-index: 100;
}
/deep/.el-carousel--horizontal {
  overflow-y: hidden;
}
/deep/.el-carousel__arrow {
  top: 235px;
  background-color: #313359 !important;
  width: 20px !important;
  height: 20px !important;
}
/deep/ .el-carousel__indicator--horizontal .el-carousel__button {
  width: 10px;
  height: 10px;
  background: #616775;
  border: 1px solid 616775;
  border-radius: 50%;
  opacity: 0.5;
}
/deep/ .el-carousel__indicator--horizontal.is-active .el-carousel__button {
  width: 10px;
  height: 10px;
  background: #5d93ed;
  border-radius: 50%;
  opacity: 1;
}
/deep/.el-progress__text {
  margin-left: 20px;
  color: #dedee4;
}
.base_information {
  width: 100%;
  height: 10px;
  background-color: #424c65;
  border-radius: 5px;
}
.tixing {
  position: relative;
  width: 100%;
  height: 10px;
  line-height: 10px;
  background-color: #303462;
  border-radius: 6px;
  overflow: hidden;
  .tixing_text {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 10;
    border-radius: 5px;
    height: 100%;
  }
  .tixing-pro {
    color: #fff;
    padding-left: 10px;
    border-radius: 6px;
    overflow: hidden;
  }
  .tixing-back0 {
    background-color: #7948ea;
  }
  .tixing-back1 {
    background-color: #00baad;
  }
  .tixing-back2 {
    background-color: #3478ef;
  }
  .tixing-back3 {
    background-color: #3478ef;
  }
  .tixing-num {
    position: absolute;
    right: 0;
    top: 0;
    z-index: 10;
    padding-right: 30px;
  }
}
</style>

相關文章