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 | <template> | 1 | <template> |
2 | <div style="margin: 100px;width: 200px;"> | 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 | <!--<Option v-for="item in data" :value="item" :label="item" :key="item">--> | 4 | <!--<Option v-for="item in data" :value="item" :label="item" :key="item">--> |
5 | <!--<span style="color: red">{{ item }}</span>--> | 5 | <!--<span style="color: red">{{ item }}</span>--> |
6 | <!--</Option>--> | 6 | <!--</Option>--> |
src/components/auto-complete/auto-complete.vue
@@ -21,7 +21,7 @@ | @@ -21,7 +21,7 @@ | ||
21 | :placeholder="placeholder" | 21 | :placeholder="placeholder" |
22 | :disabled="disabled" | 22 | :disabled="disabled" |
23 | :size="size" | 23 | :size="size" |
24 | - :icon="closeIcon" | 24 | + :icon="inputIcon" |
25 | @on-click="handleClear" | 25 | @on-click="handleClear" |
26 | @on-focus="handleFocus" | 26 | @on-focus="handleFocus" |
27 | @on-blur="handleBlur"></i-input> | 27 | @on-blur="handleBlur"></i-input> |
@@ -71,6 +71,9 @@ | @@ -71,6 +71,9 @@ | ||
71 | return oneOf(value, ['small', 'large', 'default']); | 71 | return oneOf(value, ['small', 'large', 'default']); |
72 | } | 72 | } |
73 | }, | 73 | }, |
74 | + icon: { | ||
75 | + type: String | ||
76 | + }, | ||
74 | filterMethod: { | 77 | filterMethod: { |
75 | type: [Function, Boolean], | 78 | type: [Function, Boolean], |
76 | default: false | 79 | default: false |
@@ -87,8 +90,14 @@ | @@ -87,8 +90,14 @@ | ||
87 | }; | 90 | }; |
88 | }, | 91 | }, |
89 | computed: { | 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 | filteredData () { | 102 | filteredData () { |
94 | if (this.filterMethod) { | 103 | if (this.filterMethod) { |