Commit 90399f84940fd759b029748f2552d38e9b605e38
1 parent
cd791ec1
fix #5568 ,close #5571
Showing
4 changed files
with
33 additions
and
6 deletions
Show diff stats
examples/routers/select.vue
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> | 4 | <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> |
5 | </Select> | 5 | </Select> |
6 | 6 | ||
7 | - <Select v-model="model10" multiple style="width:260px" prefix="ios-albums"> | 7 | + <Select v-model="model10" :max-tag-count="2" multiple style="width:400px" prefix="ios-albums"> |
8 | <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> | 8 | <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> |
9 | </Select> | 9 | </Select> |
10 | 10 | ||
@@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
20 | <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> | 20 | <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> |
21 | </Select> | 21 | </Select> |
22 | 22 | ||
23 | - <Select v-model="model10" multiple style="width:260px" prefix="ios-albums"> | 23 | + <Select v-model="model10" :max-tag-count="3" max-tag-placeholder="more" multiple style="width:400px" prefix="ios-albums"> |
24 | <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> | 24 | <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> |
25 | </Select> | 25 | </Select> |
26 | 26 | ||
@@ -30,7 +30,7 @@ | @@ -30,7 +30,7 @@ | ||
30 | <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> | 30 | <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> |
31 | </Select> | 31 | </Select> |
32 | 32 | ||
33 | - <Select size="small" v-model="model10" multiple style="width:260px" prefix="ios-albums"> | 33 | + <Select size="small" v-model="model10" multiple style="width:400px" prefix="ios-albums"> |
34 | <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> | 34 | <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> |
35 | </Select> | 35 | </Select> |
36 | 36 | ||
@@ -40,7 +40,7 @@ | @@ -40,7 +40,7 @@ | ||
40 | <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> | 40 | <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> |
41 | </Select> | 41 | </Select> |
42 | 42 | ||
43 | - <Select size="large" v-model="model10" multiple style="width:260px" prefix="ios-albums"> | 43 | + <Select size="large" v-model="model10" multiple style="width:400px" prefix="ios-albums"> |
44 | <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> | 44 | <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> |
45 | </Select> | 45 | </Select> |
46 | </div> | 46 | </div> |
src/components/select/select-head.vue
@@ -5,9 +5,17 @@ | @@ -5,9 +5,17 @@ | ||
5 | <Icon :type="prefix" v-if="prefix" /> | 5 | <Icon :type="prefix" v-if="prefix" /> |
6 | </slot> | 6 | </slot> |
7 | </span> | 7 | </span> |
8 | - <div class="ivu-tag ivu-tag-checked" v-for="item in selectedMultiple"> | 8 | + <div |
9 | + class="ivu-tag ivu-tag-checked" | ||
10 | + v-for="(item, index) in selectedMultiple" | ||
11 | + v-if="maxTagCount === undefined || index < maxTagCount"> | ||
9 | <span class="ivu-tag-text">{{ item.label }}</span> | 12 | <span class="ivu-tag-text">{{ item.label }}</span> |
10 | <Icon type="ios-close" @click.native.stop="removeTag(item)"></Icon> | 13 | <Icon type="ios-close" @click.native.stop="removeTag(item)"></Icon> |
14 | + </div><div class="ivu-tag ivu-tag-checked" v-if="maxTagCount !== undefined && selectedMultiple.length > maxTagCount"> | ||
15 | + <span class="ivu-tag-text ivu-select-max-tag"> | ||
16 | + <template v-if="maxTagPlaceholder">{{ maxTagPlaceholder }}</template> | ||
17 | + <template v-else>+ {{ selectedMultiple.length - maxTagCount }}...</template> | ||
18 | + </span> | ||
11 | </div> | 19 | </div> |
12 | <span | 20 | <span |
13 | :class="singleDisplayClasses" | 21 | :class="singleDisplayClasses" |
@@ -86,6 +94,14 @@ | @@ -86,6 +94,14 @@ | ||
86 | prefix: { | 94 | prefix: { |
87 | type: String | 95 | type: String |
88 | }, | 96 | }, |
97 | + // 3.4.0 | ||
98 | + maxTagCount: { | ||
99 | + type: Number | ||
100 | + }, | ||
101 | + // 3.4.0 | ||
102 | + maxTagPlaceholder: { | ||
103 | + type: String | ||
104 | + } | ||
89 | }, | 105 | }, |
90 | data () { | 106 | data () { |
91 | return { | 107 | return { |
src/components/select/select.vue
@@ -41,6 +41,8 @@ | @@ -41,6 +41,8 @@ | ||
41 | :initial-label="initialLabel" | 41 | :initial-label="initialLabel" |
42 | :placeholder="placeholder" | 42 | :placeholder="placeholder" |
43 | :query-prop="query" | 43 | :query-prop="query" |
44 | + :max-tag-count="maxTagCount" | ||
45 | + :max-tag-placeholder="maxTagPlaceholder" | ||
44 | 46 | ||
45 | @on-query-change="onQueryChange" | 47 | @on-query-change="onQueryChange" |
46 | @on-input-focus="isFocused = true" | 48 | @on-input-focus="isFocused = true" |
@@ -239,9 +241,18 @@ | @@ -239,9 +241,18 @@ | ||
239 | transferClassName: { | 241 | transferClassName: { |
240 | type: String | 242 | type: String |
241 | }, | 243 | }, |
244 | + // 3.4.0 | ||
242 | prefix: { | 245 | prefix: { |
243 | type: String | 246 | type: String |
244 | }, | 247 | }, |
248 | + // 3.4.0 | ||
249 | + maxTagCount: { | ||
250 | + type: Number | ||
251 | + }, | ||
252 | + // 3.4.0 | ||
253 | + maxTagPlaceholder: { | ||
254 | + type: String | ||
255 | + } | ||
245 | }, | 256 | }, |
246 | mounted(){ | 257 | mounted(){ |
247 | this.$on('on-select-selected', this.onOptionClick); | 258 | this.$on('on-select-selected', this.onOptionClick); |
src/styles/components/select.less
@@ -208,7 +208,7 @@ | @@ -208,7 +208,7 @@ | ||
208 | margin: 3px 4px 3px 0; | 208 | margin: 3px 4px 3px 0; |
209 | max-width: 99%; | 209 | max-width: 99%; |
210 | position: relative; | 210 | position: relative; |
211 | - span{ | 211 | + span:not(.ivu-select-max-tag){ |
212 | display: block; | 212 | display: block; |
213 | margin-right: 14px; | 213 | margin-right: 14px; |
214 | overflow: hidden; | 214 | overflow: hidden; |