Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<view class="example-search">
<t-search
v-model="value"
v-model:value="value"
center
placeholder="搜索预设文案"
@change="onChange"
Expand Down
14 changes: 8 additions & 6 deletions packages/uniapp-components/search/search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -216,7 +219,7 @@ export default {

nextTick().then(() => {
this.dataValue = value;
this.$emit('change', {
this.emitChange({
value,
trigger: 'input-change',
});
Expand All @@ -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) {
Expand All @@ -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',
});
Expand Down
Loading