记录一次使用element-ui 进度条的示例程序

3 篇文章 0 订阅

在线调试地址

HTML

@import url("//unpkg.com/element-ui@2.4.11/lib/theme-chalk/index.css");
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/element-ui@2.4.11/lib/index.js"></script>
<div id="app">
	<div>
		<el-progress :text-inside="true" :stroke-width="18" :percentage="used" :color="color"></el-progress>
	</div>
	<div>
		<el-input v-model="used" placeholder="请输入内容"></el-input>
	</div>

</div>

js

var app = new Vue({
	el: '#app',
  data: {
  	used: 50,
    color: 'red'
  },
  methods: {
  	
  },
  watch: {
  	used: function(v, v2){
    	if(v >= 80){
      	this.color = "red";
      } else if (v >= 60){
      	this.color = "orange";
      } else {
      	this.color = "blue";
      }
    }
  }
});

在列表中使用:

html
<td>
	<div>
		<el-progress :text-inside="true" :stroke-width="18" :percentage="item.used" :color="item.used|color"></el-progress>
	</div>
</td>
js
Vue.filter('color', function (input) {
    if (input == null){
        return "#f56c6c";
    }
    if (typeof input != "number"){
        return "#f56c6c";
    }
    if (input >= 90){
        return "#f56c6c";
    } else if (input >= 80){
        return "orange";
    } else {
        return "#409EFF";
    }
});
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值