Merge pull request #3487 from xiaofengsha/pr007
rate组件添加allowClear属性,通过点击可以把当前评分清零
This commit is contained in:
commit
ca1b7bfaa6
2 changed files with 15 additions and 2 deletions
|
@ -2,6 +2,8 @@
|
||||||
<div>
|
<div>
|
||||||
<Rate v-model="value"></Rate>
|
<Rate v-model="value"></Rate>
|
||||||
<Rate allow-half v-model="valueHalf"></Rate>
|
<Rate allow-half v-model="valueHalf"></Rate>
|
||||||
|
<Rate clearable v-model="valueClear"></Rate>
|
||||||
|
<Rate clearable allow-half v-model="valueClearHalf"></Rate>
|
||||||
<!--<Rate show-text v-model="valueText"></Rate>-->
|
<!--<Rate show-text v-model="valueText"></Rate>-->
|
||||||
<!--<Rate show-text allow-half v-model="valueCustomText">-->
|
<!--<Rate show-text allow-half v-model="valueCustomText">-->
|
||||||
<!--<span style="color: #f5a623">{{ valueCustomText }}</span>-->
|
<!--<span style="color: #f5a623">{{ valueCustomText }}</span>-->
|
||||||
|
@ -17,7 +19,9 @@
|
||||||
valueHalf: 2.5,
|
valueHalf: 2.5,
|
||||||
valueText: 3,
|
valueText: 3,
|
||||||
valueCustomText: 4.0,
|
valueCustomText: 4.0,
|
||||||
valueDisabled: 2.4
|
valueDisabled: 2.4,
|
||||||
|
valueClear: 1,
|
||||||
|
valueClearHalf: 1.5,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,10 @@
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
type: String
|
type: String
|
||||||
|
},
|
||||||
|
clearable: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
|
@ -123,8 +127,13 @@
|
||||||
},
|
},
|
||||||
handleClick (value) {
|
handleClick (value) {
|
||||||
if (this.disabled) return;
|
if (this.disabled) return;
|
||||||
// value++;
|
//value++;
|
||||||
if (this.isHalf) value -= 0.5;
|
if (this.isHalf) value -= 0.5;
|
||||||
|
|
||||||
|
if(this.clearable && Math.abs(value - this.currentValue) < 0.01) {
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
this.currentValue = value;
|
this.currentValue = value;
|
||||||
this.$emit('input', value);
|
this.$emit('input', value);
|
||||||
this.$emit('on-change', value);
|
this.$emit('on-change', value);
|
||||||
|
|
Loading…
Add table
Reference in a new issue