weapp版本升级到1.11.7
"version": "1.11.7"
This commit is contained in:
1 parent
a3c886146a
commit
66ba21dd7b
67 files changed
+566
-365
No files matched your search
@@ -85,18 +85,18 @@ function equal(value1, value2) {
|
||||
},
|
||||
created: function () {
|
||||
this.setData({
|
||||
currentValue: this.format(this.data.value),
|
||||
currentValue: this.format(this.data.value).newValue,
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
observeValue: function () {
|
||||
var value = this.data.value;
|
||||
this.setData({ currentValue: this.format(value) });
|
||||
this.setData({ currentValue: this.format(value).newValue });
|
||||
},
|
||||
check: function () {
|
||||
var val = this.format(this.data.currentValue);
|
||||
if (!equal(val, this.data.currentValue)) {
|
||||
this.setData({ currentValue: val });
|
||||
var newValue = this.format(this.data.currentValue).newValue;
|
||||
if (!equal(newValue, this.data.currentValue)) {
|
||||
this.setData({ currentValue: newValue });
|
||||
}
|
||||
},
|
||||
isDisabled: function (type) {
|
||||
@@ -110,10 +110,10 @@ function equal(value1, value2) {
|
||||
this.$emit('focus', event.detail);
|
||||
},
|
||||
onBlur: function (event) {
|
||||
var value = this.format(event.detail.value);
|
||||
this.setData({ currentValue: value });
|
||||
this.emitChange(value);
|
||||
this.$emit('blur', __assign(__assign({}, event.detail), { value: value }));
|
||||
var data = this.format(event.detail.value);
|
||||
this.setData({ currentValue: data.newValue });
|
||||
this.emitChange(data);
|
||||
this.$emit('blur', __assign(__assign({}, event.detail), { value: +data.newValue }));
|
||||
},
|
||||
// filter illegal characters
|
||||
filter: function (value) {
|
||||
@@ -123,17 +123,16 @@ function equal(value1, value2) {
|
||||
}
|
||||
return value;
|
||||
},
|
||||
// limit value range
|
||||
format: function (value) {
|
||||
value = this.filter(value);
|
||||
// filter illegal characters and format integer
|
||||
var safeValue = this.filter(value);
|
||||
// format range
|
||||
value = value === '' ? 0 : +value;
|
||||
value = Math.max(Math.min(this.data.max, value), this.data.min);
|
||||
var rangeValue = Math.max(Math.min(this.data.max, +safeValue), this.data.min);
|
||||
// format decimal
|
||||
if ((0, validator_1.isDef)(this.data.decimalLength)) {
|
||||
value = value.toFixed(this.data.decimalLength);
|
||||
}
|
||||
return value;
|
||||
var newValue = (0, validator_1.isDef)(this.data.decimalLength)
|
||||
? rangeValue.toFixed(this.data.decimalLength)
|
||||
: String(rangeValue);
|
||||
return { value: value, newValue: newValue };
|
||||
},
|
||||
onInput: function (event) {
|
||||
var _a = (event.detail || {}).value, value = _a === void 0 ? '' : _a;
|
||||
@@ -141,19 +140,16 @@ function equal(value1, value2) {
|
||||
if (value === '') {
|
||||
return;
|
||||
}
|
||||
var formatted = this.filter(value);
|
||||
// limit max decimal length
|
||||
if ((0, validator_1.isDef)(this.data.decimalLength) && formatted.indexOf('.') !== -1) {
|
||||
var pair = formatted.split('.');
|
||||
formatted = "".concat(pair[0], ".").concat(pair[1].slice(0, this.data.decimalLength));
|
||||
}
|
||||
var formatted = this.format(value);
|
||||
this.emitChange(formatted);
|
||||
},
|
||||
emitChange: function (value) {
|
||||
emitChange: function (data) {
|
||||
var value = data.value, newValue = data.newValue;
|
||||
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: function () {
|
||||
var type = this.type;
|
||||
@@ -162,7 +158,7 @@ function equal(value1, value2) {
|
||||
return;
|
||||
}
|
||||
var diff = type === 'minus' ? -this.data.step : +this.data.step;
|
||||
var value = this.format(add(+this.data.currentValue, diff));
|
||||
var value = this.format(String(add(+this.data.currentValue, diff)));
|
||||
this.emitChange(value);
|
||||
this.$emit(type);
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user