Commit 90399f84940fd759b029748f2552d38e9b605e38

Authored by 梁灏
1 parent cd791ec1

fix #5568 ,close #5571

examples/routers/select.vue
... ... @@ -4,7 +4,7 @@
4 4 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
5 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 8 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
9 9 </Select>
10 10  
... ... @@ -20,7 +20,7 @@
20 20 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
21 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 24 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
25 25 </Select>
26 26  
... ... @@ -30,7 +30,7 @@
30 30 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
31 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 34 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
35 35 </Select>
36 36  
... ... @@ -40,7 +40,7 @@
40 40 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
41 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 44 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
45 45 </Select>
46 46 </div>
... ...
src/components/select/select-head.vue
... ... @@ -5,9 +5,17 @@
5 5 <Icon :type="prefix" v-if="prefix" />
6 6 </slot>
7 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 12 <span class="ivu-tag-text">{{ item.label }}</span>
10 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 19 </div>
12 20 <span
13 21 :class="singleDisplayClasses"
... ... @@ -86,6 +94,14 @@
86 94 prefix: {
87 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 106 data () {
91 107 return {
... ...
src/components/select/select.vue
... ... @@ -41,6 +41,8 @@
41 41 :initial-label="initialLabel"
42 42 :placeholder="placeholder"
43 43 :query-prop="query"
  44 + :max-tag-count="maxTagCount"
  45 + :max-tag-placeholder="maxTagPlaceholder"
44 46  
45 47 @on-query-change="onQueryChange"
46 48 @on-input-focus="isFocused = true"
... ... @@ -239,9 +241,18 @@
239 241 transferClassName: {
240 242 type: String
241 243 },
  244 + // 3.4.0
242 245 prefix: {
243 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 257 mounted(){
247 258 this.$on('on-select-selected', this.onOptionClick);
... ...
src/styles/components/select.less
... ... @@ -208,7 +208,7 @@
208 208 margin: 3px 4px 3px 0;
209 209 max-width: 99%;
210 210 position: relative;
211   - span{
  211 + span:not(.ivu-select-max-tag){
212 212 display: block;
213 213 margin-right: 14px;
214 214 overflow: hidden;
... ...