From 1137640c3da9a66e8ef96c291518957adf4349cd Mon Sep 17 00:00:00 2001 From: xiaofengsha <181347204@qq.com> Date: Thu, 26 Apr 2018 01:00:39 +0800 Subject: [PATCH] rate组件添加allowClear属性,通过点击可以把当前评分清零 --- src/components/rate/rate.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/rate/rate.vue b/src/components/rate/rate.vue index 0f23245..ceacb03 100644 --- a/src/components/rate/rate.vue +++ b/src/components/rate/rate.vue @@ -45,6 +45,10 @@ }, name: { type: String + }, + allowClear: { + type: Boolean, + default: false } }, data () { @@ -123,8 +127,13 @@ }, handleClick (value) { if (this.disabled) return; -// value++; + //value++; if (this.isHalf) value -= 0.5; + + if(this.allowClear && Math.abs(value - this.currentValue) < 0.01) { + value = 0; + } + this.currentValue = value; this.$emit('input', value); this.$emit('on-change', value); -- libgit2 0.21.4