Paeg、Select add placement

This commit is contained in:
梁灏 2017-04-27 17:35:47 +08:00
parent cb6418ac5e
commit f89dd9c287
5 changed files with 30 additions and 17 deletions

View file

@ -1,16 +1,10 @@
<template> <template>
<div> <div style="margin: 100px;">
<Page :total="100" :current="current"></Page> <Page :total="100" show-sizer placement="top"></Page>
{{ current }}
<Button @click="current = 1">set current</Button>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
data () {
return {
current: 2
}
}
} }
</script> </script>

View file

@ -1,8 +1,10 @@
<template> <template>
<Select v-model="fields.pid" filterable> <div style="width: 200px;margin: 100px;">
<Option :value="0" label="一级菜单"></Option> <Select v-model="fields.pid" filterable placement="top">
<Option :value="1" label="二级菜单"></Option> <Option :value="0" label="一级菜单"></Option>
</Select> <Option :value="1" label="二级菜单"></Option>
</Select>
</div>
</template> </template>
<script> <script>

View file

@ -1,7 +1,7 @@
<template> <template>
<div v-if="showSizer || showElevator" :class="optsClasses"> <div v-if="showSizer || showElevator" :class="optsClasses">
<div v-if="showSizer" :class="sizerClasses"> <div v-if="showSizer" :class="sizerClasses">
<i-select v-model="currentPageSize" :size="size" @on-change="changeSize"> <i-select v-model="currentPageSize" :size="size" :placement="placement" @on-change="changeSize">
<i-option v-for="item in pageSizeOpts" :key="item" :value="item" style="text-align:center;">{{ item }} {{ t('i.page.page') }}</i-option> <i-option v-for="item in pageSizeOpts" :key="item" :value="item" style="text-align:center;">{{ item }} {{ t('i.page.page') }}</i-option>
</i-select> </i-select>
</div> </div>
@ -35,7 +35,8 @@
_current: Number, _current: Number,
pageSize: Number, pageSize: Number,
allPages: Number, allPages: Number,
isSmall: Boolean isSmall: Boolean,
placement: String
}, },
data () { data () {
return { return {

View file

@ -52,6 +52,7 @@
:show-sizer="showSizer" :show-sizer="showSizer"
:page-size="currentPageSize" :page-size="currentPageSize"
:page-size-opts="pageSizeOpts" :page-size-opts="pageSizeOpts"
:placement="placement"
:show-elevator="showElevator" :show-elevator="showElevator"
:_current.once="currentPage" :_current.once="currentPage"
:current="currentPage" :current="currentPage"
@ -92,6 +93,12 @@
return [10, 20, 30, 40]; return [10, 20, 30, 40];
} }
}, },
placement: {
validator (value) {
return oneOf(value, ['top', 'bottom']);
},
default: 'bottom'
},
size: { size: {
validator (value) { validator (value) {
return oneOf(value, ['small']); return oneOf(value, ['small']);

View file

@ -24,8 +24,8 @@
<Icon type="ios-close" :class="[prefixCls + '-arrow']" v-show="showCloseIcon" @click.native.stop="clearSingleSelect"></Icon> <Icon type="ios-close" :class="[prefixCls + '-arrow']" v-show="showCloseIcon" @click.native.stop="clearSingleSelect"></Icon>
<Icon type="arrow-down-b" :class="[prefixCls + '-arrow']"></Icon> <Icon type="arrow-down-b" :class="[prefixCls + '-arrow']"></Icon>
</div> </div>
<transition name="slide-up"> <transition :name="transitionName">
<Drop v-show="visible" ref="dropdown"> <Drop v-show="visible" :placement="placement" ref="dropdown">
<ul v-show="notFound" :class="[prefixCls + '-not-found']"><li>{{ localeNotFoundText }}</li></ul> <ul v-show="notFound" :class="[prefixCls + '-not-found']"><li>{{ localeNotFoundText }}</li></ul>
<ul v-show="!notFound" :class="[prefixCls + '-dropdown-list']" ref="options"><slot></slot></ul> <ul v-show="!notFound" :class="[prefixCls + '-dropdown-list']" ref="options"><slot></slot></ul>
</Drop> </Drop>
@ -85,6 +85,12 @@
}, },
notFoundText: { notFoundText: {
type: String type: String
},
placement: {
validator (value) {
return oneOf(value, ['top', 'bottom']);
},
default: 'bottom'
} }
}, },
data () { data () {
@ -161,6 +167,9 @@
} else { } else {
return this.notFoundText; return this.notFoundText;
} }
},
transitionName () {
return this.placement === 'bottom' ? 'slide-up' : 'slide-down';
} }
}, },
methods: { methods: {