|
|
@@ -45,15 +45,15 @@ VantComponent({
|
|
|
showClear: false
|
|
|
},
|
|
|
created() {
|
|
|
- this.value = this.data.value;
|
|
|
- this.setData({ innerValue: this.value });
|
|
|
+ // this.value = this.data.value;
|
|
|
+ this.setData({ innerValue: this.data.value });
|
|
|
},
|
|
|
methods: {
|
|
|
onInput(event) {
|
|
|
const { value = '' } = event.detail || {};
|
|
|
- this.value = value;
|
|
|
+ // this.value = value;
|
|
|
+ this.emitChange(value);
|
|
|
this.setShowClear();
|
|
|
- this.emitChange();
|
|
|
},
|
|
|
onFocus(event) {
|
|
|
this.focused = true;
|
|
|
@@ -71,25 +71,24 @@ VantComponent({
|
|
|
onClear() {
|
|
|
this.setData({ innerValue: '' });
|
|
|
this.value = '';
|
|
|
+ this.emitChange('');
|
|
|
+ this.$emit('clear', '');
|
|
|
this.setShowClear();
|
|
|
- wx.nextTick(() => {
|
|
|
- this.emitChange();
|
|
|
- this.$emit('clear', '');
|
|
|
- });
|
|
|
},
|
|
|
onConfirm(event) {
|
|
|
const { value = '' } = event.detail || {};
|
|
|
- this.value = value;
|
|
|
+ // this.value = value;
|
|
|
+ this.setData({ innerValue: '' });
|
|
|
this.setShowClear();
|
|
|
this.$emit('confirm', value);
|
|
|
},
|
|
|
setValue(value) {
|
|
|
- this.value = value;
|
|
|
+ // this.value = value;
|
|
|
this.setShowClear();
|
|
|
if (value === '') {
|
|
|
this.setData({ innerValue: '' });
|
|
|
}
|
|
|
- this.emitChange();
|
|
|
+ this.emitChange(value);
|
|
|
},
|
|
|
onLineChange(event) {
|
|
|
this.$emit('linechange', event.detail);
|
|
|
@@ -97,18 +96,16 @@ VantComponent({
|
|
|
onKeyboardHeightChange(event) {
|
|
|
this.$emit('keyboardheightchange', event.detail);
|
|
|
},
|
|
|
- emitChange() {
|
|
|
- this.setData({ value: this.value });
|
|
|
- wx.nextTick(() => {
|
|
|
- this.$emit('input', this.value);
|
|
|
- this.$emit('change', this.value);
|
|
|
- });
|
|
|
+ emitChange(value) {
|
|
|
+ this.setData({ innerValue: value });
|
|
|
+ this.$emit('input', value);
|
|
|
+ this.$emit('change', value);
|
|
|
},
|
|
|
setShowClear() {
|
|
|
const { clearable, readonly } = this.data;
|
|
|
- const { focused, value } = this;
|
|
|
+ const { focused } = this;
|
|
|
this.setData({
|
|
|
- showClear: !!clearable && !!focused && !!value && !readonly
|
|
|
+ showClear: !!clearable && !!focused && !!this.data.innerValue && !readonly
|
|
|
});
|
|
|
},
|
|
|
noop() {}
|