bug
This commit is contained in:
@@ -81,10 +81,14 @@ export default {
|
||||
set(val) {
|
||||
this.$emit('update:limit', val)
|
||||
}
|
||||
},
|
||||
maxPage() {
|
||||
return Math.ceil(this.total / this.pageSize) || 1
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleSizeChange(val) {
|
||||
// 当页面大小改变时,检查当前页是否还有效
|
||||
if (this.currentPage * val > this.total) {
|
||||
this.currentPage = 1
|
||||
}
|
||||
@@ -94,6 +98,16 @@ export default {
|
||||
}
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
// 计算最大页数,进行边界检查
|
||||
const maxPage = Math.ceil(this.total / this.pageSize) || 1;
|
||||
|
||||
// 如果请求的页码超出范围,限制在有效范围内
|
||||
if (val > maxPage) {
|
||||
val = maxPage;
|
||||
} else if (val < 1) {
|
||||
val = 1;
|
||||
}
|
||||
|
||||
this.$emit('pagination', { page: val, limit: this.pageSize })
|
||||
if (this.autoScroll) {
|
||||
scrollTo(0, 800)
|
||||
|
||||
Reference in New Issue
Block a user