mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
[bugfix] Field: with form component (#447)
This commit is contained in:
parent
5e65176fb7
commit
ac358578c7
@ -43,10 +43,7 @@ Component({
|
||||
},
|
||||
value: {
|
||||
type: null,
|
||||
value: '',
|
||||
observer(currentValue) {
|
||||
this.setData({ currentValue });
|
||||
}
|
||||
value: ''
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
@ -60,14 +57,7 @@ Component({
|
||||
|
||||
data: {
|
||||
focused: false,
|
||||
showClear: false,
|
||||
currentValue: ''
|
||||
},
|
||||
|
||||
attached() {
|
||||
this.setData({
|
||||
currentValue: this.data.value
|
||||
});
|
||||
showClear: false
|
||||
},
|
||||
|
||||
methods: {
|
||||
@ -76,7 +66,7 @@ Component({
|
||||
this.triggerEvent('input', value);
|
||||
this.triggerEvent('change', value);
|
||||
this.setData({
|
||||
currentValue: value,
|
||||
value,
|
||||
showClear: this.getShowClear({ value })
|
||||
});
|
||||
},
|
||||
@ -105,7 +95,7 @@ Component({
|
||||
getShowClear(options) {
|
||||
const {
|
||||
focused = this.data.focused,
|
||||
value = this.data.currentValue
|
||||
value = this.data.value
|
||||
} = options;
|
||||
|
||||
return this.data.clearable && focused && value !== '' && !this.data.readonly;
|
||||
@ -113,7 +103,7 @@ Component({
|
||||
|
||||
onClear() {
|
||||
this.setData({
|
||||
currentValue: '',
|
||||
value: '',
|
||||
showClear: this.getShowClear({ value: '' })
|
||||
});
|
||||
this.triggerEvent('input', '');
|
||||
@ -121,7 +111,7 @@ Component({
|
||||
},
|
||||
|
||||
onConfirm() {
|
||||
this.triggerEvent('confirm', this.data.currentValue);
|
||||
this.triggerEvent('confirm', this.data.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -15,7 +15,7 @@
|
||||
wx:if="{{ type === 'textarea' }}"
|
||||
class="input-class van-field__control van-field__textarea {{ inputAlign ? 'van-field--' + inputAlign : '' }} {{ error ? 'van-field--error' : '' }} {{ disabled ? 'van-field__control--disabled' : '' }}"
|
||||
focus="{{ focus }}"
|
||||
value="{{ currentValue }}"
|
||||
value="{{ value }}"
|
||||
disabled="{{ disabled }}"
|
||||
readonly="{{ readonly }}"
|
||||
maxlength="{{ maxlength }}"
|
||||
@ -33,7 +33,7 @@
|
||||
class="input-class van-field__control {{ inputAlign ? 'van-field--' + inputAlign : '' }} {{ error ? 'van-field--error' : '' }} {{ disabled ? 'van-field__control--disabled' : '' }}"
|
||||
type="{{ type }}"
|
||||
focus="{{ focus }}"
|
||||
value="{{ currentValue }}"
|
||||
value="{{ value }}"
|
||||
disabled="{{ disabled }}"
|
||||
readonly="{{ readonly }}"
|
||||
maxlength="{{ maxlength }}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user