Skip to content

Commit

Permalink
fixes #27
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyrilszq committed Jun 27, 2017
1 parent ac4c909 commit b74db66
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/components/Table/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
</table>
</div>
<div v-show="pagination && pagination.total > 0" :class="[prefixCls + '-table-pagination']">
<pagination ref="pager" :total="pagination.total" :page-size="pagination.pageSize" :show-jumper="true" :show-size-changer="true" @pagination-page-change="changePage" @pagination-size-change="changeSize"></pagination>
<pagination ref="pager" :total="pagination.total" :currPage="pagination.currPage" :page-size="pagination.pageSize" :show-jumper="true" :show-size-changer="true" @change="changePage" @pagination-page-change="changePage" @pagination-size-change="changeSize"></pagination>
</div>
</div>
</template>
Expand Down Expand Up @@ -215,7 +215,10 @@ export default {
mounted () {
if (this.pagination.total > 0) {
let pager = this.$refs.pager
this.dataList = this.originDataSource.slice(pager.currPage || 0, pager.pageSize)
let startIndex = (pager.currPage - 1) * pager.pageSize
startIndex = startIndex >= pager.total ? 0 : startIndex
// this.dataList = this.originDataSource.slice(pager.currPage || 0, pager.pageSize)
this.dataList = this.originDataSource.slice(startIndex, startIndex + pager.pageSize)
}
},
computed: {
Expand Down
7 changes: 5 additions & 2 deletions src/components/Table/demo/pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ title:
增加pagination属性以分页,
```
const pagination = {
total: data.length
total: data.length,
pageSize: 20,
currPage: 1
}
```
Expand Down Expand Up @@ -75,7 +77,8 @@ for (let i = 0; i < 46; i++) {
const pagination = {
total: data.length,
pageSize: 20
pageSize: 20,
currPage: 1
}
// 配置选择数据的选项
Expand Down

0 comments on commit b74db66

Please sign in to comment.