Skip to content

Commit

Permalink
feature: pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
cern committed Apr 24, 2023
1 parent 24aa818 commit 66e97b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 5 additions & 1 deletion pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
</div>
</div>
<div class="layout-content">
<nuxt-child keep-alive :datalist="searchList" to="/song" />
<a-config-provider :locale="locale">
<nuxt-child keep-alive :datalist="searchList" to="/song" />
</a-config-provider>
</div>
</a-layout-content>
<a-layout-footer style="text-align: center">
Expand All @@ -65,6 +67,7 @@

<script>
import csvToJson from 'csvtojson'
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
const testDataList = []
for (let i = 0; i < 100; i++) {
Expand All @@ -80,6 +83,7 @@ export default {
name: 'IndexPage',
data () {
return {
locale: zhCN,
selectionDefaultValue: 'all',
inputVal: '',
songListData: [],
Expand Down
16 changes: 14 additions & 2 deletions pages/index/song.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ export default {
showLoadingMore: true,
pagination: {
onChange: page => this.onPageChange(page),
pageSize: 18,
pageSize: 10,
showSizeChanger: true,
pageSizeOptions: ['10', '20', '30', '40', '50'],
showTotal: total => `${total} 首歌曲`,
onShowSizeChange: (current, pageSize) => this.onSizeChange(current, pageSize),
style: {
textAlign: 'center !important',
display: 'flex',
Expand Down Expand Up @@ -67,11 +71,19 @@ export default {
]
}
},
mounted () {},
mounted () {
const currentPageSize = localStorage.getItem('pageSize')
if (currentPageSize !== null) {
this.pagination.pageSize = currentPageSize
}
},
methods: {
onPageChange (current) {
console.log(current)
},
onSizeChange (current, pageSize) {
localStorage.setItem('pageSize', pageSize)
},
rowClick (record, index) {
return {
on: {
Expand Down

0 comments on commit 66e97b8

Please sign in to comment.