diff --git a/packages/uniapp-components/search/search.vue b/packages/uniapp-components/search/search.vue index 4a01abf2c..e280a7696 100644 --- a/packages/uniapp-components/search/search.vue +++ b/packages/uniapp-components/search/search.vue @@ -200,7 +200,10 @@ export default { this.showClearIcon = value || String(clearTrigger) === 'always'; }, - + emitChange(data) { + this.$emit('update:value', data.value); + this.$emit('change', data); + }, onInput(e) { let { value } = e.detail; // this.rawValue = value; @@ -216,7 +219,7 @@ export default { nextTick().then(() => { this.dataValue = value; - this.$emit('change', { + this.emitChange({ value, trigger: 'input-change', }); @@ -240,11 +243,11 @@ export default { handleClear() { this.dataValue = ''; this.isSearching = false; - this.$emit('clear', { value: '' }); - this.$emit('change', { + this.emitChange({ value: '', trigger: 'clear', }); + this.$emit('clear', { value: '' }); }, onConfirm(e) { @@ -261,8 +264,7 @@ export default { const item = this.resultList[index]; this.dataValue = item; this.isSelected = true; - - this.$emit('change', { + this.emitChange({ value: item, trigger: 'option-click', });