Commit 7d535fc91510e6a2ec793de5f6d3a3ddc2802bb6
Committed by
GitHub
Merge branch '2.0' into 2.0-backtop
Showing
8 changed files
with
71 additions
and
40 deletions
Show diff stats
CHANGE.md
| @@ -42,4 +42,6 @@ Menu 的 activeKey 改为 activeName,openKeys 改为 openNames | @@ -42,4 +42,6 @@ Menu 的 activeKey 改为 activeName,openKeys 改为 openNames | ||
| 42 | ### Cascader | 42 | ### Cascader |
| 43 | Caspanel 的 sublist 从 prop -> data | 43 | Caspanel 的 sublist 从 prop -> data |
| 44 | ### Select | 44 | ### Select |
| 45 | -model 改为 value,支持 v-model | ||
| 46 | \ No newline at end of file | 45 | \ No newline at end of file |
| 46 | +model 改为 value,支持 v-model | ||
| 47 | +### Page | ||
| 48 | +class 改为 className | ||
| 47 | \ No newline at end of file | 49 | \ No newline at end of file |
README.md
examples/app.vue
| @@ -45,6 +45,7 @@ li + li { border-left: solid 1px #bbb; padding-left: 10px; margin-left: 10px; } | @@ -45,6 +45,7 @@ li + li { border-left: solid 1px #bbb; padding-left: 10px; margin-left: 10px; } | ||
| 45 | <li><router-link to="/cascader">Cascader</router-link></li> | 45 | <li><router-link to="/cascader">Cascader</router-link></li> |
| 46 | <li><router-link to="/select">Select</router-link></li> | 46 | <li><router-link to="/select">Select</router-link></li> |
| 47 | <li><router-link to="/backtop">Backtop</router-link></li> | 47 | <li><router-link to="/backtop">Backtop</router-link></li> |
| 48 | + <li><router-link to="/page">Page</router-link></li> | ||
| 48 | </ul> | 49 | </ul> |
| 49 | </nav> | 50 | </nav> |
| 50 | <router-view></router-view> | 51 | <router-view></router-view> |
examples/main.js
| @@ -144,6 +144,10 @@ const router = new VueRouter({ | @@ -144,6 +144,10 @@ const router = new VueRouter({ | ||
| 144 | { | 144 | { |
| 145 | path: '/backtop', | 145 | path: '/backtop', |
| 146 | component: require('./routers/back-top.vue') | 146 | component: require('./routers/back-top.vue') |
| 147 | + }, | ||
| 148 | + { | ||
| 149 | + path: '/page', | ||
| 150 | + component: require('./routers/page.vue') | ||
| 147 | } | 151 | } |
| 148 | ] | 152 | ] |
| 149 | }); | 153 | }); |
examples/routers/page.vue
| 1 | <template> | 1 | <template> |
| 2 | - <Page :total="1000" show-sizer show-elevator show-total class="classr" :style="{float: 'right'}" @on-page-size-change="pc"></Page> | ||
| 3 | - <br><br> | ||
| 4 | - <Page :total="1000" show-sizer show-elevator show-total size="small" class="classr2"></Page> | ||
| 5 | - <br><br> | ||
| 6 | - <Page :current="2" :total="50" simple></Page> | 2 | + <div> |
| 3 | + <Page :total="1000" show-sizer show-elevator show-total class="classr" :style="{float: 'right'}" @on-page-size-change="pc"></Page> | ||
| 4 | + <br><br> | ||
| 5 | + <Page :total="1000" show-sizer show-elevator show-total size="small" class="classr2"></Page> | ||
| 6 | + <br><br> | ||
| 7 | + <Page :current="2" :total="50" simple></Page> | ||
| 8 | + </div> | ||
| 7 | </template> | 9 | </template> |
| 8 | <script> | 10 | <script> |
| 9 | import { Page } from 'iview'; | 11 | import { Page } from 'iview'; |
src/components/page/options.vue
| 1 | <template> | 1 | <template> |
| 2 | <div v-if="showSizer || showElevator" :class="optsClasses"> | 2 | <div v-if="showSizer || showElevator" :class="optsClasses"> |
| 3 | <div v-if="showSizer" :class="sizerClasses"> | 3 | <div v-if="showSizer" :class="sizerClasses"> |
| 4 | - <i-select :model.sync="pageSize" :size="size" @on-change="changeSize"> | 4 | + <i-select v-model="currentPageSize" :size="size" @on-change="changeSize"> |
| 5 | <i-option v-for="item in pageSizeOpts" :value="item" style="text-align:center;">{{ item }} {{ t('i.page.page') }}</i-option> | 5 | <i-option v-for="item in pageSizeOpts" :value="item" style="text-align:center;">{{ item }} {{ t('i.page.page') }}</i-option> |
| 6 | </i-select> | 6 | </i-select> |
| 7 | </div> | 7 | </div> |
| @@ -24,6 +24,7 @@ | @@ -24,6 +24,7 @@ | ||
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | export default { | 26 | export default { |
| 27 | + name: 'PageOption', | ||
| 27 | mixins: [ Locale ], | 28 | mixins: [ Locale ], |
| 28 | components: { iSelect, iOption }, | 29 | components: { iSelect, iOption }, |
| 29 | props: { | 30 | props: { |
| @@ -36,6 +37,16 @@ | @@ -36,6 +37,16 @@ | ||
| 36 | allPages: Number, | 37 | allPages: Number, |
| 37 | isSmall: Boolean | 38 | isSmall: Boolean |
| 38 | }, | 39 | }, |
| 40 | + data () { | ||
| 41 | + return { | ||
| 42 | + currentPageSize: this.pageSize | ||
| 43 | + } | ||
| 44 | + }, | ||
| 45 | + watch: { | ||
| 46 | + pageSize (val) { | ||
| 47 | + this.currentPageSize = val; | ||
| 48 | + } | ||
| 49 | + }, | ||
| 39 | computed: { | 50 | computed: { |
| 40 | size () { | 51 | size () { |
| 41 | return this.isSmall ? 'small' : 'default'; | 52 | return this.isSmall ? 'small' : 'default'; |
| @@ -58,7 +69,7 @@ | @@ -58,7 +69,7 @@ | ||
| 58 | }, | 69 | }, |
| 59 | methods: { | 70 | methods: { |
| 60 | changeSize () { | 71 | changeSize () { |
| 61 | - this.$emit('on-size', this.pageSize); | 72 | + this.$emit('on-size', this.currentPageSize); |
| 62 | }, | 73 | }, |
| 63 | changePage (event) { | 74 | changePage (event) { |
| 64 | let val = event.target.value.trim(); | 75 | let val = event.target.value.trim(); |
| @@ -86,4 +97,4 @@ | @@ -86,4 +97,4 @@ | ||
| 86 | } | 97 | } |
| 87 | } | 98 | } |
| 88 | }; | 99 | }; |
| 89 | -</script> | 100 | -</script> |
| 101 | +</script> | ||
| 90 | \ No newline at end of file | 102 | \ No newline at end of file |
src/components/page/page.vue
| @@ -6,10 +6,10 @@ | @@ -6,10 +6,10 @@ | ||
| 6 | @click="prev"> | 6 | @click="prev"> |
| 7 | <a><i class="ivu-icon ivu-icon-ios-arrow-left"></i></a> | 7 | <a><i class="ivu-icon ivu-icon-ios-arrow-left"></i></a> |
| 8 | </li> | 8 | </li> |
| 9 | - <div :class="simplePagerClasses" :title="current + '/' + allPages"> | 9 | + <div :class="simplePagerClasses" :title="currentPage + '/' + allPages"> |
| 10 | <input | 10 | <input |
| 11 | type="text" | 11 | type="text" |
| 12 | - :value="current" | 12 | + :value="currentPage" |
| 13 | @keydown="keyDown" | 13 | @keydown="keyDown" |
| 14 | @keyup="keyUp" | 14 | @keyup="keyUp" |
| 15 | @change="keyUp"> | 15 | @change="keyUp"> |
| @@ -34,13 +34,13 @@ | @@ -34,13 +34,13 @@ | ||
| 34 | <a><i class="ivu-icon ivu-icon-ios-arrow-left"></i></a> | 34 | <a><i class="ivu-icon ivu-icon-ios-arrow-left"></i></a> |
| 35 | </li> | 35 | </li> |
| 36 | <li title="1" :class="firstPageClasses" @click="changePage(1)"><a>1</a></li> | 36 | <li title="1" :class="firstPageClasses" @click="changePage(1)"><a>1</a></li> |
| 37 | - <li :title="t('i.page.prev5')" v-if="current - 3 > 1" :class="[prefixCls + '-item-jump-prev']" @click="fastPrev"><a><i class="ivu-icon ivu-icon-ios-arrow-left"></i></a></li> | ||
| 38 | - <li :title="current - 2" v-if="current - 2 > 1" :class="[prefixCls + '-item']" @click="changePage(current - 2)"><a>{{ current - 2 }}</a></li> | ||
| 39 | - <li :title="current - 1" v-if="current - 1 > 1" :class="[prefixCls + '-item']" @click="changePage(current - 1)"><a>{{ current - 1 }}</a></li> | ||
| 40 | - <li :title="current" v-if="current != 1 && current != allPages" :class="[prefixCls + '-item',prefixCls + '-item-active']"><a>{{ current }}</a></li> | ||
| 41 | - <li :title="current + 1" v-if="current + 1 < allPages" :class="[prefixCls + '-item']" @click="changePage(current + 1)"><a>{{ current + 1 }}</a></li> | ||
| 42 | - <li :title="current + 2" v-if="current + 2 < allPages" :class="[prefixCls + '-item']" @click="changePage(current + 2)"><a>{{ current + 2 }}</a></li> | ||
| 43 | - <li :title="t('i.page.next5')" v-if="current + 3 < allPages" :class="[prefixCls + '-item-jump-next']" @click="fastNext"><a><i class="ivu-icon ivu-icon-ios-arrow-right"></i></a></li> | 37 | + <li :title="t('i.page.prev5')" v-if="currentPage - 3 > 1" :class="[prefixCls + '-item-jump-prev']" @click="fastPrev"><a><i class="ivu-icon ivu-icon-ios-arrow-left"></i></a></li> |
| 38 | + <li :title="currentPage - 2" v-if="currentPage - 2 > 1" :class="[prefixCls + '-item']" @click="changePage(currentPage - 2)"><a>{{ currentPage - 2 }}</a></li> | ||
| 39 | + <li :title="currentPage - 1" v-if="currentPage - 1 > 1" :class="[prefixCls + '-item']" @click="changePage(currentPage - 1)"><a>{{ currentPage - 1 }}</a></li> | ||
| 40 | + <li :title="currentPage" v-if="currentPage != 1 && currentPage != allPages" :class="[prefixCls + '-item',prefixCls + '-item-active']"><a>{{ currentPage }}</a></li> | ||
| 41 | + <li :title="currentPage + 1" v-if="currentPage + 1 < allPages" :class="[prefixCls + '-item']" @click="changePage(currentPage + 1)"><a>{{ currentPage + 1 }}</a></li> | ||
| 42 | + <li :title="currentPage + 2" v-if="currentPage + 2 < allPages" :class="[prefixCls + '-item']" @click="changePage(currentPage + 2)"><a>{{ currentPage + 2 }}</a></li> | ||
| 43 | + <li :title="t('i.page.next5')" v-if="currentPage + 3 < allPages" :class="[prefixCls + '-item-jump-next']" @click="fastNext"><a><i class="ivu-icon ivu-icon-ios-arrow-right"></i></a></li> | ||
| 44 | <li :title="allPages" v-if="allPages > 1" :class="lastPageClasses" @click="changePage(allPages)"><a>{{ allPages }}</a></li> | 44 | <li :title="allPages" v-if="allPages > 1" :class="lastPageClasses" @click="changePage(allPages)"><a>{{ allPages }}</a></li> |
| 45 | <li | 45 | <li |
| 46 | :title="t('i.page.next')" | 46 | :title="t('i.page.next')" |
| @@ -50,11 +50,11 @@ | @@ -50,11 +50,11 @@ | ||
| 50 | </li> | 50 | </li> |
| 51 | <Options | 51 | <Options |
| 52 | :show-sizer="showSizer" | 52 | :show-sizer="showSizer" |
| 53 | - :page-size="pageSize" | 53 | + :page-size="currentPageSize" |
| 54 | :page-size-opts="pageSizeOpts" | 54 | :page-size-opts="pageSizeOpts" |
| 55 | :show-elevator="showElevator" | 55 | :show-elevator="showElevator" |
| 56 | - :_current.once="current" | ||
| 57 | - :current.sync="current" | 56 | + :_current.once="currentPage" |
| 57 | + :current="currentPage" | ||
| 58 | :all-pages="allPages" | 58 | :all-pages="allPages" |
| 59 | :is-small="isSmall" | 59 | :is-small="isSmall" |
| 60 | @on-size="onSize" | 60 | @on-size="onSize" |
| @@ -70,6 +70,7 @@ | @@ -70,6 +70,7 @@ | ||
| 70 | const prefixCls = 'ivu-page'; | 70 | const prefixCls = 'ivu-page'; |
| 71 | 71 | ||
| 72 | export default { | 72 | export default { |
| 73 | + name: 'Page', | ||
| 73 | mixins: [ Locale ], | 74 | mixins: [ Locale ], |
| 74 | components: { Options }, | 75 | components: { Options }, |
| 75 | props: { | 76 | props: { |
| @@ -112,7 +113,7 @@ | @@ -112,7 +113,7 @@ | ||
| 112 | type: Boolean, | 113 | type: Boolean, |
| 113 | default: false | 114 | default: false |
| 114 | }, | 115 | }, |
| 115 | - class: { | 116 | + className: { |
| 116 | type: String | 117 | type: String |
| 117 | }, | 118 | }, |
| 118 | style: { | 119 | style: { |
| @@ -121,15 +122,25 @@ | @@ -121,15 +122,25 @@ | ||
| 121 | }, | 122 | }, |
| 122 | data () { | 123 | data () { |
| 123 | return { | 124 | return { |
| 124 | - prefixCls: prefixCls | 125 | + prefixCls: prefixCls, |
| 126 | + currentPage: this.current, | ||
| 127 | + currentPageSize: this.pageSize | ||
| 125 | }; | 128 | }; |
| 126 | }, | 129 | }, |
| 130 | + watch: { | ||
| 131 | + current (val) { | ||
| 132 | + this.currentPage = val; | ||
| 133 | + }, | ||
| 134 | + pageSize (val) { | ||
| 135 | + this.currentPageSize = val; | ||
| 136 | + } | ||
| 137 | + }, | ||
| 127 | computed: { | 138 | computed: { |
| 128 | isSmall () { | 139 | isSmall () { |
| 129 | return !!this.size; | 140 | return !!this.size; |
| 130 | }, | 141 | }, |
| 131 | allPages () { | 142 | allPages () { |
| 132 | - const allPage = Math.ceil(this.total / this.pageSize); | 143 | + const allPage = Math.ceil(this.total / this.currentPageSize); |
| 133 | return (allPage === 0) ? 1 : allPage; | 144 | return (allPage === 0) ? 1 : allPage; |
| 134 | }, | 145 | }, |
| 135 | simpleWrapClasses () { | 146 | simpleWrapClasses () { |
| @@ -137,7 +148,7 @@ | @@ -137,7 +148,7 @@ | ||
| 137 | `${prefixCls}`, | 148 | `${prefixCls}`, |
| 138 | `${prefixCls}-simple`, | 149 | `${prefixCls}-simple`, |
| 139 | { | 150 | { |
| 140 | - [`${this.class}`]: !!this.class | 151 | + [`${this.className}`]: !!this.className |
| 141 | } | 152 | } |
| 142 | ]; | 153 | ]; |
| 143 | }, | 154 | }, |
| @@ -148,7 +159,7 @@ | @@ -148,7 +159,7 @@ | ||
| 148 | return [ | 159 | return [ |
| 149 | `${prefixCls}`, | 160 | `${prefixCls}`, |
| 150 | { | 161 | { |
| 151 | - [`${this.class}`]: !!this.class, | 162 | + [`${this.className}`]: !!this.className, |
| 152 | 'mini': !!this.size | 163 | 'mini': !!this.size |
| 153 | } | 164 | } |
| 154 | ]; | 165 | ]; |
| @@ -157,7 +168,7 @@ | @@ -157,7 +168,7 @@ | ||
| 157 | return [ | 168 | return [ |
| 158 | `${prefixCls}-prev`, | 169 | `${prefixCls}-prev`, |
| 159 | { | 170 | { |
| 160 | - [`${prefixCls}-disabled`]: this.current === 1 | 171 | + [`${prefixCls}-disabled`]: this.currentPage === 1 |
| 161 | } | 172 | } |
| 162 | ]; | 173 | ]; |
| 163 | }, | 174 | }, |
| @@ -165,7 +176,7 @@ | @@ -165,7 +176,7 @@ | ||
| 165 | return [ | 176 | return [ |
| 166 | `${prefixCls}-next`, | 177 | `${prefixCls}-next`, |
| 167 | { | 178 | { |
| 168 | - [`${prefixCls}-disabled`]: this.current === this.allPages | 179 | + [`${prefixCls}-disabled`]: this.currentPage === this.allPages |
| 169 | } | 180 | } |
| 170 | ]; | 181 | ]; |
| 171 | }, | 182 | }, |
| @@ -173,7 +184,7 @@ | @@ -173,7 +184,7 @@ | ||
| 173 | return [ | 184 | return [ |
| 174 | `${prefixCls}-item`, | 185 | `${prefixCls}-item`, |
| 175 | { | 186 | { |
| 176 | - [`${prefixCls}-item-active`]: this.current === 1 | 187 | + [`${prefixCls}-item-active`]: this.currentPage === 1 |
| 177 | } | 188 | } |
| 178 | ]; | 189 | ]; |
| 179 | }, | 190 | }, |
| @@ -181,34 +192,34 @@ | @@ -181,34 +192,34 @@ | ||
| 181 | return [ | 192 | return [ |
| 182 | `${prefixCls}-item`, | 193 | `${prefixCls}-item`, |
| 183 | { | 194 | { |
| 184 | - [`${prefixCls}-item-active`]: this.current === this.allPages | 195 | + [`${prefixCls}-item-active`]: this.currentPage === this.allPages |
| 185 | } | 196 | } |
| 186 | ]; | 197 | ]; |
| 187 | } | 198 | } |
| 188 | }, | 199 | }, |
| 189 | methods: { | 200 | methods: { |
| 190 | changePage (page) { | 201 | changePage (page) { |
| 191 | - if (this.current != page) { | ||
| 192 | - this.current = page; | 202 | + if (this.currentPage != page) { |
| 203 | + this.currentPage = page; | ||
| 193 | this.$emit('on-change', page); | 204 | this.$emit('on-change', page); |
| 194 | } | 205 | } |
| 195 | }, | 206 | }, |
| 196 | prev () { | 207 | prev () { |
| 197 | - const current = this.current; | 208 | + const current = this.currentPage; |
| 198 | if (current <= 1) { | 209 | if (current <= 1) { |
| 199 | return false; | 210 | return false; |
| 200 | } | 211 | } |
| 201 | this.changePage(current - 1); | 212 | this.changePage(current - 1); |
| 202 | }, | 213 | }, |
| 203 | next () { | 214 | next () { |
| 204 | - const current = this.current; | 215 | + const current = this.currentPage; |
| 205 | if (current >= this.allPages) { | 216 | if (current >= this.allPages) { |
| 206 | return false; | 217 | return false; |
| 207 | } | 218 | } |
| 208 | this.changePage(current + 1); | 219 | this.changePage(current + 1); |
| 209 | }, | 220 | }, |
| 210 | fastPrev () { | 221 | fastPrev () { |
| 211 | - const page = this.current - 5; | 222 | + const page = this.currentPage - 5; |
| 212 | if (page > 0) { | 223 | if (page > 0) { |
| 213 | this.changePage(page); | 224 | this.changePage(page); |
| 214 | } else { | 225 | } else { |
| @@ -216,7 +227,7 @@ | @@ -216,7 +227,7 @@ | ||
| 216 | } | 227 | } |
| 217 | }, | 228 | }, |
| 218 | fastNext () { | 229 | fastNext () { |
| 219 | - const page = this.current + 5; | 230 | + const page = this.currentPage + 5; |
| 220 | if (page > this.allPages) { | 231 | if (page > this.allPages) { |
| 221 | this.changePage(this.allPages); | 232 | this.changePage(this.allPages); |
| 222 | } else { | 233 | } else { |
| @@ -224,7 +235,7 @@ | @@ -224,7 +235,7 @@ | ||
| 224 | } | 235 | } |
| 225 | }, | 236 | }, |
| 226 | onSize (pageSize) { | 237 | onSize (pageSize) { |
| 227 | - this.pageSize = pageSize; | 238 | + this.currentPageSize = pageSize; |
| 228 | this.changePage(1); | 239 | this.changePage(1); |
| 229 | this.$emit('on-page-size-change', pageSize); | 240 | this.$emit('on-page-size-change', pageSize); |
| 230 | }, | 241 | }, |
src/index.js
| @@ -24,7 +24,7 @@ import Menu from './components/menu'; | @@ -24,7 +24,7 @@ import Menu from './components/menu'; | ||
| 24 | // import Message from './components/message'; | 24 | // import Message from './components/message'; |
| 25 | // import Modal from './components/modal'; | 25 | // import Modal from './components/modal'; |
| 26 | // import Notice from './components/notice'; | 26 | // import Notice from './components/notice'; |
| 27 | -// import Page from './components/page'; | 27 | +import Page from './components/page'; |
| 28 | import Poptip from './components/poptip'; | 28 | import Poptip from './components/poptip'; |
| 29 | import Progress from './components/progress'; | 29 | import Progress from './components/progress'; |
| 30 | import Radio from './components/radio'; | 30 | import Radio from './components/radio'; |
| @@ -85,7 +85,7 @@ const iview = { | @@ -85,7 +85,7 @@ const iview = { | ||
| 85 | // Notice, | 85 | // Notice, |
| 86 | iOption: Option, | 86 | iOption: Option, |
| 87 | OptionGroup, | 87 | OptionGroup, |
| 88 | - // Page, | 88 | + Page, |
| 89 | Panel: Collapse.Panel, | 89 | Panel: Collapse.Panel, |
| 90 | Poptip, | 90 | Poptip, |
| 91 | Progress, | 91 | Progress, |