Skip to content

Commit

Permalink
Merge pull request #946 from dcloudio/uni-combox-clearable
Browse files Browse the repository at this point in the history
feat:uni-comobox新增clearAble属性
  • Loading branch information
GRCmade authored Aug 30, 2024
2 parents 83c57d9 + 76111b0 commit 2c9c16b
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions uni_modules/uni-combox/components/uni-combox/uni-combox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
<text>{{label}}</text>
</view>
<view class="uni-combox__input-box">
<input class="uni-combox__input" type="text" :placeholder="placeholder"
placeholder-class="uni-combox__input-plac" v-model="inputVal" @input="onInput" @focus="onFocus"
@blur="onBlur" />
<uni-icons :type="showSelector? 'top' : 'bottom'" size="14" color="#999" @click="toggleSelector">
<input class="uni-combox__input" type="text" :placeholder="placeholder" placeholder-class="uni-combox__input-plac"
v-model="inputVal" @input="onInput" @focus="onFocus" @blur="onBlur" />
<uni-icons v-if="!inputVal || !clearAble" :type="showSelector? 'top' : 'bottom'" size="14" color="#999" @click="toggleSelector">
</uni-icons>
<uni-icons v-if="inputVal && clearAble" type="clear" size="24" color="#999" @click="clean">
</uni-icons>
</view>
<view class="uni-combox__selector" v-if="showSelector">
Expand All @@ -16,8 +17,8 @@
<view class="uni-combox__selector-empty" v-if="filterCandidatesLength === 0">
<text>{{emptyTips}}</text>
</view>
<view class="uni-combox__selector-item" v-for="(item,index) in filterCandidates" :key="index"
@click="onSelectorClick(index)">
<view class="uni-combox__selector-item" v-for="(item,index) in filterCandidates" :key="index"
@click="onSelectorClick(index)">
<text>{{item}}</text>
</view>
</scroll-view>
Expand All @@ -41,6 +42,10 @@
name: 'uniCombox',
emits: ['input', 'update:modelValue'],
props: {
clearAble: {
type: Boolean,
default: false
},
border: {
type: Boolean,
default: true
Expand Down Expand Up @@ -143,6 +148,10 @@
this.$emit('input', this.inputVal)
this.$emit('update:modelValue', this.inputVal)
})
},
clean() {
this.inputVal = ''
this.onInput()
}
}
}
Expand Down Expand Up @@ -272,4 +281,4 @@
.uni-combox__no-border {
border: none;
}
</style>
</style>

1 comment on commit 2c9c16b

@GRCmade
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.