Commit 9013c49d7c9b0a04200a98705bd128c3e7df5864

Authored by 梁灏
1 parent 90399f84

update Select style with filterable & prefix

examples/routers/select.vue
1 <template> 1 <template>
2 <div style="margin: 100px;"> 2 <div style="margin: 100px;">
3 - <Select v-model="model1" style="width:200px" prefix="ios-albums"> 3 + <Select v-model="model1" filterable style="width:200px" prefix="ios-albums">
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" :max-tag-count="2" multiple style="width:400px" prefix="ios-albums"> 7 + <Select v-model="model10" filterable :max-tag-count="2" multiple style="width:400px">
  8 + <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
  9 + </Select>
  10 +
  11 + <Select v-model="model10" filterable :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> 12 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
9 </Select> 13 </Select>
10 14
src/components/select/select-head.vue
1 <template> 1 <template>
2 - <div @click="onHeaderClick"> 2 + <div @click="onHeaderClick" :class="headCls">
3 <span :class="[prefixCls + '-prefix']" v-if="$slots.prefix || prefix"> 3 <span :class="[prefixCls + '-prefix']" v-if="$slots.prefix || prefix">
4 <slot name="prefix"> 4 <slot name="prefix">
5 <Icon :type="prefix" v-if="prefix" /> 5 <Icon :type="prefix" v-if="prefix" />
@@ -168,6 +168,12 @@ @@ -168,6 +168,12 @@
168 }, 168 },
169 selectedMultiple(){ 169 selectedMultiple(){
170 return this.multiple ? this.values : []; 170 return this.multiple ? this.values : [];
  171 + },
  172 + // 使用 prefix 时,在 filterable
  173 + headCls () {
  174 + return {
  175 + [`${prefixCls}-head-flex`]: this.filterable && (this.$slots.prefix || this.prefix)
  176 + };
171 } 177 }
172 }, 178 },
173 methods: { 179 methods: {
src/styles/components/select.less
@@ -185,7 +185,7 @@ @@ -185,7 +185,7 @@
185 } 185 }
186 186
187 &-multiple &-input{ 187 &-multiple &-input{
188 - height: @input-height-base - 3px; 188 + height: @input-height-base - 2px;
189 line-height: @input-height-base; 189 line-height: @input-height-base;
190 padding: 0 0 0 4px; 190 padding: 0 0 0 4px;
191 } 191 }
@@ -260,6 +260,9 @@ @@ -260,6 +260,9 @@
260 &-prefix{ 260 &-prefix{
261 display: inline-block; 261 display: inline-block;
262 vertical-align: middle; 262 vertical-align: middle;
  263 + i{
  264 + vertical-align: top;
  265 + }
263 } 266 }
264 &-head-with-prefix{ 267 &-head-with-prefix{
265 display: inline-block !important; 268 display: inline-block !important;
@@ -271,6 +274,15 @@ @@ -271,6 +274,15 @@
271 &-single &-head-with-prefix, &-multiple &-head-with-prefix{ 274 &-single &-head-with-prefix, &-multiple &-head-with-prefix{
272 padding-left: 0 !important; 275 padding-left: 0 !important;
273 } 276 }
  277 +
  278 + &-head-flex{
  279 + display: flex;
  280 + align-items: center;
  281 + }
  282 +
  283 + &-multiple &-head-flex &-prefix{
  284 + margin-right: 4px;
  285 + }
274 } 286 }
275 287
276 .select-item(@select-prefix-cls, @select-item-prefix-cls); 288 .select-item(@select-prefix-cls, @select-item-prefix-cls);