1
0
mirror of https://gitee.com/vant-contrib/vant-weapp.git synced 2025-04-06 03:58:05 +08:00

[bugfix] Field: with form component ()

This commit is contained in:
neverland 2018-08-21 14:35:40 +08:00 committed by GitHub
parent 5e65176fb7
commit ac358578c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 18 deletions
packages/field

@ -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 }}"