weapp版本升级到1.11.7

"version": "1.11.7"
This commit is contained in:
Abin committed 2026-01-07 13:54:40 +08:00
1 parent a3c886146a
commit 66ba21dd7b
67 files changed
+566 -365

No files matched your search

+23 -27
View File
@@ -72,18 +72,18 @@ VantComponent({
},
created() {
this.setData({
currentValue: this.format(this.data.value),
currentValue: this.format(this.data.value).newValue,
});
},
methods: {
observeValue() {
const { value } = this.data;
this.setData({ currentValue: this.format(value) });
this.setData({ currentValue: this.format(value).newValue });
},
check() {
const val = this.format(this.data.currentValue);
if (!equal(val, this.data.currentValue)) {
this.setData({ currentValue: val });
const { newValue } = this.format(this.data.currentValue);
if (!equal(newValue, this.data.currentValue)) {
this.setData({ currentValue: newValue });
}
},
isDisabled(type) {
@@ -97,10 +97,10 @@ VantComponent({
this.$emit('focus', event.detail);
},
onBlur(event) {
const value = this.format(event.detail.value);
this.setData({ currentValue: value });
this.emitChange(value);
this.$emit('blur', Object.assign(Object.assign({}, event.detail), { value }));
const data = this.format(event.detail.value);
this.setData({ currentValue: data.newValue });
this.emitChange(data);
this.$emit('blur', Object.assign(Object.assign({}, event.detail), { value: +data.newValue }));
},
// filter illegal characters
filter(value) {
@@ -110,17 +110,16 @@ VantComponent({
}
return value;
},
// limit value range
format(value) {
value = this.filter(value);
// filter illegal characters and format integer
const safeValue = this.filter(value);
// format range
value = value === '' ? 0 : +value;
value = Math.max(Math.min(this.data.max, value), this.data.min);
const rangeValue = Math.max(Math.min(this.data.max, +safeValue), this.data.min);
// format decimal
if (isDef(this.data.decimalLength)) {
value = value.toFixed(this.data.decimalLength);
}
return value;
const newValue = isDef(this.data.decimalLength)
? rangeValue.toFixed(this.data.decimalLength)
: String(rangeValue);
return { value, newValue };
},
onInput(event) {
const { value = '' } = event.detail || {};
@@ -128,19 +127,16 @@ VantComponent({
if (value === '') {
return;
}
let formatted = this.filter(value);
// limit max decimal length
if (isDef(this.data.decimalLength) && formatted.indexOf('.') !== -1) {
const pair = formatted.split('.');
formatted = `${pair[0]}.${pair[1].slice(0, this.data.decimalLength)}`;
}
const formatted = this.format(value);
this.emitChange(formatted);
},
emitChange(value) {
emitChange(data) {
const { value, newValue } = data;
if (!this.data.asyncChange) {
this.setData({ currentValue: value });
// fix when input 11. parsed to 11, unable to enter decimal
this.setData({ currentValue: +value === +newValue ? value : newValue });
}
this.$emit('change', value);
this.$emit('change', +newValue);
},
onChange() {
const { type } = this;
@@ -149,7 +145,7 @@ VantComponent({
return;
}
const diff = type === 'minus' ? -this.data.step : +this.data.step;
const value = this.format(add(+this.data.currentValue, diff));
const value = this.format(String(add(+this.data.currentValue, diff)));
this.emitChange(value);
this.$emit(type);
},