Commit f89dd9c28740685deb98ec9fe3f6b144decc4d76
1 parent
cb6418ac
Paeg、Select add placement
Showing
5 changed files
with
30 additions
and
17 deletions
Show diff stats
examples/routers/page.vue
| 1 | 1 | <template> |
| 2 | - <div> | |
| 3 | - <Page :total="100" :current="current"></Page> | |
| 4 | - {{ current }} | |
| 5 | - <Button @click="current = 1">set current</Button> | |
| 2 | + <div style="margin: 100px;"> | |
| 3 | + <Page :total="100" show-sizer placement="top"></Page> | |
| 6 | 4 | </div> |
| 7 | 5 | </template> |
| 8 | 6 | <script> |
| 9 | 7 | export default { |
| 10 | - data () { | |
| 11 | - return { | |
| 12 | - current: 2 | |
| 13 | - } | |
| 14 | - } | |
| 8 | + | |
| 15 | 9 | } |
| 16 | 10 | </script> | ... | ... |
examples/routers/select.vue
| 1 | 1 | <template> |
| 2 | - <Select v-model="fields.pid" filterable> | |
| 3 | - <Option :value="0" label="一级菜单"></Option> | |
| 4 | - <Option :value="1" label="二级菜单"></Option> | |
| 5 | - </Select> | |
| 2 | + <div style="width: 200px;margin: 100px;"> | |
| 3 | + <Select v-model="fields.pid" filterable placement="top"> | |
| 4 | + <Option :value="0" label="一级菜单"></Option> | |
| 5 | + <Option :value="1" label="二级菜单"></Option> | |
| 6 | + </Select> | |
| 7 | + </div> | |
| 6 | 8 | </template> |
| 7 | 9 | |
| 8 | 10 | <script> | ... | ... |
src/components/page/options.vue
| 1 | 1 | <template> |
| 2 | 2 | <div v-if="showSizer || showElevator" :class="optsClasses"> |
| 3 | 3 | <div v-if="showSizer" :class="sizerClasses"> |
| 4 | - <i-select v-model="currentPageSize" :size="size" @on-change="changeSize"> | |
| 4 | + <i-select v-model="currentPageSize" :size="size" :placement="placement" @on-change="changeSize"> | |
| 5 | 5 | <i-option v-for="item in pageSizeOpts" :key="item" :value="item" style="text-align:center;">{{ item }} {{ t('i.page.page') }}</i-option> |
| 6 | 6 | </i-select> |
| 7 | 7 | </div> |
| ... | ... | @@ -35,7 +35,8 @@ |
| 35 | 35 | _current: Number, |
| 36 | 36 | pageSize: Number, |
| 37 | 37 | allPages: Number, |
| 38 | - isSmall: Boolean | |
| 38 | + isSmall: Boolean, | |
| 39 | + placement: String | |
| 39 | 40 | }, |
| 40 | 41 | data () { |
| 41 | 42 | return { | ... | ... |
src/components/page/page.vue
| ... | ... | @@ -52,6 +52,7 @@ |
| 52 | 52 | :show-sizer="showSizer" |
| 53 | 53 | :page-size="currentPageSize" |
| 54 | 54 | :page-size-opts="pageSizeOpts" |
| 55 | + :placement="placement" | |
| 55 | 56 | :show-elevator="showElevator" |
| 56 | 57 | :_current.once="currentPage" |
| 57 | 58 | :current="currentPage" |
| ... | ... | @@ -92,6 +93,12 @@ |
| 92 | 93 | return [10, 20, 30, 40]; |
| 93 | 94 | } |
| 94 | 95 | }, |
| 96 | + placement: { | |
| 97 | + validator (value) { | |
| 98 | + return oneOf(value, ['top', 'bottom']); | |
| 99 | + }, | |
| 100 | + default: 'bottom' | |
| 101 | + }, | |
| 95 | 102 | size: { |
| 96 | 103 | validator (value) { |
| 97 | 104 | return oneOf(value, ['small']); | ... | ... |
src/components/select/select.vue
| ... | ... | @@ -24,8 +24,8 @@ |
| 24 | 24 | <Icon type="ios-close" :class="[prefixCls + '-arrow']" v-show="showCloseIcon" @click.native.stop="clearSingleSelect"></Icon> |
| 25 | 25 | <Icon type="arrow-down-b" :class="[prefixCls + '-arrow']"></Icon> |
| 26 | 26 | </div> |
| 27 | - <transition name="slide-up"> | |
| 28 | - <Drop v-show="visible" ref="dropdown"> | |
| 27 | + <transition :name="transitionName"> | |
| 28 | + <Drop v-show="visible" :placement="placement" ref="dropdown"> | |
| 29 | 29 | <ul v-show="notFound" :class="[prefixCls + '-not-found']"><li>{{ localeNotFoundText }}</li></ul> |
| 30 | 30 | <ul v-show="!notFound" :class="[prefixCls + '-dropdown-list']" ref="options"><slot></slot></ul> |
| 31 | 31 | </Drop> |
| ... | ... | @@ -85,6 +85,12 @@ |
| 85 | 85 | }, |
| 86 | 86 | notFoundText: { |
| 87 | 87 | type: String |
| 88 | + }, | |
| 89 | + placement: { | |
| 90 | + validator (value) { | |
| 91 | + return oneOf(value, ['top', 'bottom']); | |
| 92 | + }, | |
| 93 | + default: 'bottom' | |
| 88 | 94 | } |
| 89 | 95 | }, |
| 90 | 96 | data () { |
| ... | ... | @@ -161,6 +167,9 @@ |
| 161 | 167 | } else { |
| 162 | 168 | return this.notFoundText; |
| 163 | 169 | } |
| 170 | + }, | |
| 171 | + transitionName () { | |
| 172 | + return this.placement === 'bottom' ? 'slide-up' : 'slide-down'; | |
| 164 | 173 | } |
| 165 | 174 | }, |
| 166 | 175 | methods: { | ... | ... |