This commit is contained in:
陈嘉涵 2018-08-21 14:36:54 +08:00
parent ac358578c7
commit 7e4547ccd5
2 changed files with 8 additions and 18 deletions

22
dist/field/index.js vendored
View File

@ -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);
}
}
});

View File

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