Commit 9cc6213ca4b4d7ad08099444393d153b8dd97a6a
1 parent
b575fe2c
update AutoComplete
Showing
2 changed files
with
13 additions
and
4 deletions
Show diff stats
examples/routers/auto-complete.vue
1 | 1 | <template> |
2 | 2 | <div style="margin: 100px;width: 200px;"> |
3 | - <AutoComplete transfer v-model="value" :data="data" @on-search="handleSearch" @on-change="hc" :filter-method="fm"> | |
3 | + <AutoComplete transfer v-model="value" clearable icon="ios-search" :data="data" @on-search="handleSearch" @on-change="hc" :filter-method="fm"> | |
4 | 4 | <!--<Option v-for="item in data" :value="item" :label="item" :key="item">--> |
5 | 5 | <!--<span style="color: red">{{ item }}</span>--> |
6 | 6 | <!--</Option>--> | ... | ... |
src/components/auto-complete/auto-complete.vue
... | ... | @@ -21,7 +21,7 @@ |
21 | 21 | :placeholder="placeholder" |
22 | 22 | :disabled="disabled" |
23 | 23 | :size="size" |
24 | - :icon="closeIcon" | |
24 | + :icon="inputIcon" | |
25 | 25 | @on-click="handleClear" |
26 | 26 | @on-focus="handleFocus" |
27 | 27 | @on-blur="handleBlur"></i-input> |
... | ... | @@ -71,6 +71,9 @@ |
71 | 71 | return oneOf(value, ['small', 'large', 'default']); |
72 | 72 | } |
73 | 73 | }, |
74 | + icon: { | |
75 | + type: String | |
76 | + }, | |
74 | 77 | filterMethod: { |
75 | 78 | type: [Function, Boolean], |
76 | 79 | default: false |
... | ... | @@ -87,8 +90,14 @@ |
87 | 90 | }; |
88 | 91 | }, |
89 | 92 | computed: { |
90 | - closeIcon () { | |
91 | - return this.clearable && this.currentValue ? 'ios-close' : ''; | |
93 | + inputIcon () { | |
94 | + let icon = ''; | |
95 | + if (this.clearable && this.currentValue) { | |
96 | + icon = 'ios-close'; | |
97 | + } else if (this.icon) { | |
98 | + icon = this.icon; | |
99 | + } | |
100 | + return icon; | |
92 | 101 | }, |
93 | 102 | filteredData () { |
94 | 103 | if (this.filterMethod) { | ... | ... |