This commit is contained in:
梁灏 2019-04-09 10:45:01 +08:00
parent cd791ec115
commit 90399f8494
4 changed files with 33 additions and 6 deletions

View file

@ -4,7 +4,7 @@
<Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select> </Select>
<Select v-model="model10" multiple style="width:260px" prefix="ios-albums"> <Select v-model="model10" :max-tag-count="2" multiple style="width:400px" prefix="ios-albums">
<Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select> </Select>
@ -20,7 +20,7 @@
<Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select> </Select>
<Select v-model="model10" multiple style="width:260px" prefix="ios-albums"> <Select v-model="model10" :max-tag-count="3" max-tag-placeholder="more" multiple style="width:400px" prefix="ios-albums">
<Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select> </Select>
@ -30,7 +30,7 @@
<Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select> </Select>
<Select size="small" v-model="model10" multiple style="width:260px" prefix="ios-albums"> <Select size="small" v-model="model10" multiple style="width:400px" prefix="ios-albums">
<Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select> </Select>
@ -40,7 +40,7 @@
<Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select> </Select>
<Select size="large" v-model="model10" multiple style="width:260px" prefix="ios-albums"> <Select size="large" v-model="model10" multiple style="width:400px" prefix="ios-albums">
<Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select> </Select>
</div> </div>

View file

@ -5,9 +5,17 @@
<Icon :type="prefix" v-if="prefix" /> <Icon :type="prefix" v-if="prefix" />
</slot> </slot>
</span> </span>
<div class="ivu-tag ivu-tag-checked" v-for="item in selectedMultiple"> <div
class="ivu-tag ivu-tag-checked"
v-for="(item, index) in selectedMultiple"
v-if="maxTagCount === undefined || index < maxTagCount">
<span class="ivu-tag-text">{{ item.label }}</span> <span class="ivu-tag-text">{{ item.label }}</span>
<Icon type="ios-close" @click.native.stop="removeTag(item)"></Icon> <Icon type="ios-close" @click.native.stop="removeTag(item)"></Icon>
</div><div class="ivu-tag ivu-tag-checked" v-if="maxTagCount !== undefined && selectedMultiple.length > maxTagCount">
<span class="ivu-tag-text ivu-select-max-tag">
<template v-if="maxTagPlaceholder">{{ maxTagPlaceholder }}</template>
<template v-else>+ {{ selectedMultiple.length - maxTagCount }}...</template>
</span>
</div> </div>
<span <span
:class="singleDisplayClasses" :class="singleDisplayClasses"
@ -86,6 +94,14 @@
prefix: { prefix: {
type: String type: String
}, },
// 3.4.0
maxTagCount: {
type: Number
},
// 3.4.0
maxTagPlaceholder: {
type: String
}
}, },
data () { data () {
return { return {

View file

@ -41,6 +41,8 @@
:initial-label="initialLabel" :initial-label="initialLabel"
:placeholder="placeholder" :placeholder="placeholder"
:query-prop="query" :query-prop="query"
:max-tag-count="maxTagCount"
:max-tag-placeholder="maxTagPlaceholder"
@on-query-change="onQueryChange" @on-query-change="onQueryChange"
@on-input-focus="isFocused = true" @on-input-focus="isFocused = true"
@ -239,9 +241,18 @@
transferClassName: { transferClassName: {
type: String type: String
}, },
// 3.4.0
prefix: { prefix: {
type: String type: String
}, },
// 3.4.0
maxTagCount: {
type: Number
},
// 3.4.0
maxTagPlaceholder: {
type: String
}
}, },
mounted(){ mounted(){
this.$on('on-select-selected', this.onOptionClick); this.$on('on-select-selected', this.onOptionClick);

View file

@ -208,7 +208,7 @@
margin: 3px 4px 3px 0; margin: 3px 4px 3px 0;
max-width: 99%; max-width: 99%;
position: relative; position: relative;
span{ span:not(.ivu-select-max-tag){
display: block; display: block;
margin-right: 14px; margin-right: 14px;
overflow: hidden; overflow: hidden;