chore: improve watcher

This commit is contained in:
陈嘉涵 2020-01-18 10:58:12 +08:00
parent f928063d6a
commit c895bf1739
6 changed files with 14 additions and 16 deletions

View File

@ -66,8 +66,8 @@ export default createComponent({
},
watch: {
value() {
this.code = this.value;
value(val) {
this.code = val;
this.setValues();
},

View File

@ -118,9 +118,7 @@ export default createComponent({
},
watch: {
type() {
this.reset();
},
type: 'reset',
value(val) {
if (val) {

View File

@ -127,10 +127,10 @@ export default createComponent({
watch: {
rate: {
handler() {
handler(rate) {
this.startTime = Date.now();
this.startRate = this.value;
this.endRate = format(this.rate);
this.endRate = format(rate);
this.increase = this.endRate > this.startRate;
this.duration = Math.abs(
((this.startRate - this.endRate) * 1000) / this.speed

View File

@ -65,9 +65,9 @@ export default createComponent({
},
watch: {
show() {
show(val) {
if (!this.transition) {
this.$emit(this.show ? 'show' : 'hide');
this.$emit(val ? 'show' : 'hide');
}
}
},

View File

@ -73,8 +73,8 @@ export default createComponent({
},
watch: {
defaultIndex() {
this.setIndex(this.defaultIndex);
defaultIndex(val) {
this.setIndex(val);
}
},

View File

@ -112,17 +112,17 @@ export default createComponent({
},
watch: {
max: 'check',
min: 'check',
integer: 'check',
decimalLength: 'check',
value(val) {
if (!equal(val, this.currentValue)) {
this.currentValue = this.format(val);
}
},
max: 'check',
min: 'check',
integer: 'check',
decimalLength: 'check',
currentValue(val) {
this.$emit('input', val);
this.$emit('change', val, { name: this.name });