Select add prefix prop and slot. close #5477
This commit is contained in:
parent
707898f2ad
commit
2739fc29cc
4 changed files with 73 additions and 8 deletions
|
@ -1,5 +1,10 @@
|
|||
<template>
|
||||
<div @click="onHeaderClick">
|
||||
<span :class="[prefixCls + '-prefix']" v-if="$slots.prefix || prefix">
|
||||
<slot name="prefix">
|
||||
<Icon :type="prefix" v-if="prefix" />
|
||||
</slot>
|
||||
</span>
|
||||
<div class="ivu-tag ivu-tag-checked" v-for="item in selectedMultiple">
|
||||
<span class="ivu-tag-text">{{ item.label }}</span>
|
||||
<Icon type="ios-close" @click.native.stop="removeTag(item)"></Icon>
|
||||
|
@ -77,7 +82,10 @@
|
|||
queryProp: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
prefix: {
|
||||
type: String
|
||||
},
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
|
@ -92,6 +100,7 @@
|
|||
singleDisplayClasses(){
|
||||
const {filterable, multiple, showPlaceholder} = this;
|
||||
return [{
|
||||
[prefixCls + '-head-with-prefix']: this.$slots.prefix || this.prefix,
|
||||
[prefixCls + '-placeholder']: showPlaceholder && !filterable,
|
||||
[prefixCls + '-selected-value']: !showPlaceholder && !multiple && !filterable,
|
||||
}];
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
:multiple="multiple"
|
||||
:values="values"
|
||||
:clearable="canBeCleared"
|
||||
:prefix="prefix"
|
||||
:disabled="disabled"
|
||||
:remote="remote"
|
||||
:input-element-id="elementId"
|
||||
|
@ -44,7 +45,9 @@
|
|||
@on-input-focus="isFocused = true"
|
||||
@on-input-blur="isFocused = false"
|
||||
@on-clear="clearSingleSelect"
|
||||
/>
|
||||
>
|
||||
<slot name="prefix" slot="prefix"></slot>
|
||||
</select-head>
|
||||
</slot>
|
||||
</div>
|
||||
<transition name="transition-drop">
|
||||
|
@ -235,6 +238,9 @@
|
|||
transferClassName: {
|
||||
type: String
|
||||
},
|
||||
prefix: {
|
||||
type: String
|
||||
},
|
||||
},
|
||||
mounted(){
|
||||
this.$on('on-select-selected', this.onOptionClick);
|
||||
|
|
|
@ -256,6 +256,21 @@
|
|||
& &-dropdown{
|
||||
width: auto;
|
||||
}
|
||||
|
||||
&-prefix{
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
&-head-with-prefix{
|
||||
display: inline-block !important;
|
||||
vertical-align: middle;
|
||||
}
|
||||
&-single &-prefix{
|
||||
padding-left: 4px;
|
||||
}
|
||||
&-single &-head-with-prefix, &-multiple &-head-with-prefix{
|
||||
padding-left: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
.select-item(@select-prefix-cls, @select-item-prefix-cls);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue