Commit 4935594e4e234fd3494e746550400d7535f0d6ac
1 parent
93efaba8
fixed #21
fixed #21
Showing
3 changed files
with
9 additions
and
6 deletions
Show diff stats
components/page/page.vue
... | ... | @@ -41,7 +41,7 @@ |
41 | 41 | <li :title="current + 1" v-if="current + 1 < allPages" :class="[`${prefixCls}-item`]" @click="changePage(current + 1)"><a>{{ current + 1 }}</a></li> |
42 | 42 | <li :title="current + 2" v-if="current + 2 < allPages" :class="[`${prefixCls}-item`]" @click="changePage(current + 2)"><a>{{ current + 2 }}</a></li> |
43 | 43 | <li title="向后 5 页" 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> |
44 | - <li :title="'最后一页:' + allPages" :class="[`${prefixCls}-item`, {[`${prefixCls}-item-active`]: current == allPages}]" @click="changePage(allPages)"><a>{{ allPages }}</a></li> | |
44 | + <li :title="'最后一页:' + allPages" v-if="allPages > 1" :class="[`${prefixCls}-item`, {[`${prefixCls}-item-active`]: current == allPages}]" @click="changePage(allPages)"><a>{{ allPages }}</a></li> | |
45 | 45 | <li |
46 | 46 | title="下一页" |
47 | 47 | :class="nextClasses" |
... | ... | @@ -117,7 +117,8 @@ |
117 | 117 | }, |
118 | 118 | computed: { |
119 | 119 | allPages () { |
120 | - return Math.ceil(this.total / this.pageSize); | |
120 | + const allPage = Math.ceil(this.total / this.pageSize); | |
121 | + return (allPage === 0) ? 1 : allPage; | |
121 | 122 | }, |
122 | 123 | simpleWrapClasses () { |
123 | 124 | return [ | ... | ... |
local/routers/index.vue
... | ... | @@ -7,13 +7,15 @@ |
7 | 7 | <Button @click="warning">warning</Button> |
8 | 8 | <Button @click="error">error</Button> |
9 | 9 | <Button @click="confirm">confirm</Button> |
10 | - | |
10 | + <Page :total="11" :page-size="11"></Page> | |
11 | + <Page :total="11" size="small"></Page> | |
12 | + <Page :current="1" :total="0" simple></Page> | |
11 | 13 | </template> |
12 | 14 | <script> |
13 | - import { Modal, Button, Message } from 'iview'; | |
15 | + import { Modal, Button, Message, Page } from 'iview'; | |
14 | 16 | |
15 | 17 | export default { |
16 | - components: { Modal, Button }, | |
18 | + components: { Modal, Button, Page }, | |
17 | 19 | props: { |
18 | 20 | |
19 | 21 | }, | ... | ... |