Commit ac50d539aa9ad7c4ebf6ef7f77dfa514b8ddc24d
1 parent
1a4a76e9
Page add prev-text and next-text prop
Showing
3 changed files
with
20 additions
and
5 deletions
Show diff stats
examples/routers/page.vue
| 1 | <template> | 1 | <template> |
| 2 | <div> | 2 | <div> |
| 3 | - <Page :total="total" show-sizer show-elevator show-total transfer :current.sync="current"></Page> | 3 | + <Page prev-text="上一页" next-text="下一页" :total="total" show-sizer show-elevator show-total transfer :current.sync="current"></Page> |
| 4 | {{ current }} | 4 | {{ current }} |
| 5 | <Button type="primary" @click="subject">- 1</Button> | 5 | <Button type="primary" @click="subject">- 1</Button> |
| 6 | <Button type="primary" @click="change">Change</Button> | 6 | <Button type="primary" @click="change">Change</Button> |
src/components/page/page.vue
| @@ -33,7 +33,7 @@ | @@ -33,7 +33,7 @@ | ||
| 33 | :title="t('i.page.prev')" | 33 | :title="t('i.page.prev')" |
| 34 | :class="prevClasses" | 34 | :class="prevClasses" |
| 35 | @click="prev"> | 35 | @click="prev"> |
| 36 | - <a><i class="ivu-icon ivu-icon-ios-arrow-left"></i></a> | 36 | + <a><template v-if="prevText !== ''">{{ prevText }}</template><i v-else class="ivu-icon ivu-icon-ios-arrow-left"></i></a> |
| 37 | </li> | 37 | </li> |
| 38 | <li title="1" :class="firstPageClasses" @click="changePage(1)"><a>1</a></li> | 38 | <li title="1" :class="firstPageClasses" @click="changePage(1)"><a>1</a></li> |
| 39 | <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> | 39 | <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> |
| @@ -48,7 +48,7 @@ | @@ -48,7 +48,7 @@ | ||
| 48 | :title="t('i.page.next')" | 48 | :title="t('i.page.next')" |
| 49 | :class="nextClasses" | 49 | :class="nextClasses" |
| 50 | @click="next"> | 50 | @click="next"> |
| 51 | - <a><i class="ivu-icon ivu-icon-ios-arrow-right"></i></a> | 51 | + <a><template v-if="nextText !== ''">{{ nextText }}</template><i v-else class="ivu-icon ivu-icon-ios-arrow-right"></i></a> |
| 52 | </li> | 52 | </li> |
| 53 | <Options | 53 | <Options |
| 54 | :show-sizer="showSizer" | 54 | :show-sizer="showSizer" |
| @@ -132,6 +132,14 @@ | @@ -132,6 +132,14 @@ | ||
| 132 | }, | 132 | }, |
| 133 | styles: { | 133 | styles: { |
| 134 | type: Object | 134 | type: Object |
| 135 | + }, | ||
| 136 | + prevText: { | ||
| 137 | + type: String, | ||
| 138 | + default: '' | ||
| 139 | + }, | ||
| 140 | + nextText: { | ||
| 141 | + type: String, | ||
| 142 | + default: '' | ||
| 135 | } | 143 | } |
| 136 | }, | 144 | }, |
| 137 | data () { | 145 | data () { |
| @@ -188,7 +196,8 @@ | @@ -188,7 +196,8 @@ | ||
| 188 | return [ | 196 | return [ |
| 189 | `${prefixCls}-prev`, | 197 | `${prefixCls}-prev`, |
| 190 | { | 198 | { |
| 191 | - [`${prefixCls}-disabled`]: this.currentPage === 1 | 199 | + [`${prefixCls}-disabled`]: this.currentPage === 1, |
| 200 | + [`${prefixCls}-custom-text`]: this.prevText !== '' | ||
| 192 | } | 201 | } |
| 193 | ]; | 202 | ]; |
| 194 | }, | 203 | }, |
| @@ -196,7 +205,8 @@ | @@ -196,7 +205,8 @@ | ||
| 196 | return [ | 205 | return [ |
| 197 | `${prefixCls}-next`, | 206 | `${prefixCls}-next`, |
| 198 | { | 207 | { |
| 199 | - [`${prefixCls}-disabled`]: this.currentPage === this.allPages | 208 | + [`${prefixCls}-disabled`]: this.currentPage === this.allPages, |
| 209 | + [`${prefixCls}-custom-text`]: this.nextText !== '' | ||
| 200 | } | 210 | } |
| 201 | ]; | 211 | ]; |
| 202 | }, | 212 | }, |
src/styles/components/page.less
| @@ -103,6 +103,7 @@ | @@ -103,6 +103,7 @@ | ||
| 103 | &-item-jump-next { | 103 | &-item-jump-next { |
| 104 | display: inline-block; | 104 | display: inline-block; |
| 105 | vertical-align: middle; | 105 | vertical-align: middle; |
| 106 | + user-select: none; | ||
| 106 | //float: left; | 107 | //float: left; |
| 107 | min-width: @btn-circle-size; | 108 | min-width: @btn-circle-size; |
| 108 | height: @btn-circle-size; | 109 | height: @btn-circle-size; |
| @@ -224,6 +225,10 @@ | @@ -224,6 +225,10 @@ | ||
| 224 | padding: 0 8px 0 2px; | 225 | padding: 0 8px 0 2px; |
| 225 | } | 226 | } |
| 226 | } | 227 | } |
| 228 | + | ||
| 229 | + &-custom-text, &-custom-text:hover{ | ||
| 230 | + border-color: transparent; | ||
| 231 | + } | ||
| 227 | } | 232 | } |
| 228 | 233 | ||
| 229 | .@{page-prefix-cls} { | 234 | .@{page-prefix-cls} { |