el-progress入门学习

el-progress入门学习

知识点

  1. percentage为百分比,范围是0~100
  2. status的值可以为success,warning,exception
  3. format自带percentage参数,可以格式化文本显示效果
  4. text-inside设置为true,文本显示在内部
  5. stroke-width设置的直径宽度
  6. color设置颜色,可以为字符串,数组或是函数,数组元素的两个属性分别为color,percentage,想象成switch语句percentage相当于小于某百分比时,显示指定颜色
  7. type可以设置成line,circle,dashboard,分别为线性,圆形,方向盘型

效果图

在这里插入图片描述

代码

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>
</head>

<body>
    <div id="app">
        <el-progress :percentage='50'></el-progress>
        <el-progress :percentage='100'></el-progress>
        <el-progress :percentage='100' :format='formatFull'></el-progress>
        <el-progress :percentage='100' status="success"></el-progress>
        <el-progress :percentage='100' status="warning"></el-progress>
        <el-progress :percentage='100' status='exception'></el-progress>
        <el-progress :percentage='50' :text-inside='true' :stroke-width='20' status='success'></el-progress>
        <el-progress :percentage='60' :text-inside='true' :stroke-width='22' status='warning'></el-progress>
        <el-progress :percentage='70' :text-inside='true' :stroke-width='24' status='exception'></el-progress>
        <el-progress :percentage='80' :text-inside='true' :stroke-width='26'></el-progress>
        <el-progress :percentage='percentage' :color='percentageColor'></el-progress>
        <el-progress :percentage='percentage' :color='percentageColors'></el-progress>
        <el-progress :percentage='percentage' :color='percentageSetColors'></el-progress>
        <el-button-group>
            <el-button icon='el-icon-minus' @click='decrease'></el-button>
            <el-button icon='el-icon-plus' @click='increase'></el-button>
        </el-button-group><br>
        <el-progress type='circle' :percentage='0'></el-progress>
        <el-progress type='circle' :percentage='25'></el-progress>
        <el-progress type='circle' :percentage='100' status='success'></el-progress>
        <el-progress type='circle' :percentage='70' status='warning'></el-progress>
        <el-progress type='circle' :percentage='50' status='exception'></el-progress>
        <el-progress type='dashboard' :color='percentageColors' :percentage='percentage'></el-progress>
    </div>
</body>

</html>

<script>
    new Vue({
        el: "#app",
        data() {
            return {
                percentage: 30,
                percentageColor: 'blue',
                percentageColors: [
                    { color: 'red', percentage: 20 },
                    { color: 'orange', percentage: 40 },
                    { color: 'yellow', percentage: 60 },
                    { color: 'green', percentage: 80 },
                    { color: 'blue', percentage: 100 }
                ],
            }
        },
        methods: {
            formatFull(percentage) {
                return percentage === 100 ? '满' : `${percentage}%`
            },
            percentageSetColors(percentage) {
                if (percentage < 30) {
                    return "red";
                } else if (percentage < 70) {
                    return "orange";
                } else {
                    return "yellow";
                }
            },
            decrease() {
                let percentage = this.percentage;
                return this.percentage = percentage < 10 ? 0 : percentage - 10;
            },
            increase() {
                let percentage = this.percentage;
                return this.percentage = percentage > 90 ? 100 : percentage + 10;
            }
        }
    })
</script>

官网

el-progress学习官网

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

自律最差的编程狗

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值