Рефакторинг + добавлено формирование и парсинг параметров в URL

This commit is contained in:
Book Pauk
2022-09-15 20:53:28 +07:00
parent f362026a21
commit 9d3a1e45da
5 changed files with 269 additions and 69 deletions

View File

@@ -49,17 +49,18 @@ import * as utils from '../../share/utils';
const componentOptions = {
watch: {
filteredValue: function(newValue) {
if (this.validate(newValue)) {
this.error = false;
this.$emit('update:modelValue', this.string2number(newValue));
} else {
this.error = true;
}
filteredValue() {
this.checkErrorAndEmit(true);
},
modelValue: function(newValue) {
modelValue(newValue) {
this.filteredValue = newValue;
},
min() {
this.checkErrorAndEmit();
},
max() {
this.checkErrorAndEmit();
}
}
};
class NumInput {
@@ -97,6 +98,16 @@ class NumInput {
return true;
}
checkErrorAndEmit(emit = false) {
if (this.validate(this.filteredValue)) {
this.error = false;
if (emit)
this.$emit('update:modelValue', this.string2number(this.filteredValue));
} else {
this.error = true;
}
}
plus() {
const newValue = this.modelValue + this.step;
if (this.validate(newValue))