fix(stepper): fix unable update value in async change (#5191)

This commit is contained in:
landluck 2023-01-12 10:53:05 +08:00 committed by GitHub
parent 965734328c
commit e9d521a8d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View File

@ -23,6 +23,7 @@ function VantComponent<
mapKeys(vantOptions, options, { mapKeys(vantOptions, options, {
data: 'data', data: 'data',
props: 'properties', props: 'properties',
watch: 'observers',
mixins: 'behaviors', mixins: 'behaviors',
methods: 'methods', methods: 'methods',
beforeCreate: 'created', beforeCreate: 'created',

View File

@ -24,6 +24,8 @@ export type VantComponentOptions<
mixin: string; mixin: string;
}; };
watch?: Record<string, (...args: any[]) => any>;
methods?: Methods; methods?: Methods;
// lifetimes // lifetimes

View File

@ -22,7 +22,6 @@ VantComponent({
props: { props: {
value: { value: {
type: null, type: null,
observer: 'observeValue',
}, },
integer: { integer: {
type: Boolean, type: Boolean,
@ -74,6 +73,12 @@ VantComponent({
currentValue: '', currentValue: '',
}, },
watch: {
value() {
this.observeValue();
},
},
created() { created() {
this.setData({ this.setData({
currentValue: this.format(this.data.value), currentValue: this.format(this.data.value),
@ -82,11 +87,8 @@ VantComponent({
methods: { methods: {
observeValue() { observeValue() {
const { value, currentValue } = this.data; const { value } = this.data;
this.setData({ currentValue: this.format(value) });
if (!equal(value, currentValue)) {
this.setData({ currentValue: this.format(value) });
}
}, },
check() { check() {