🐛(page): 修复起始页计算逻辑

This commit is contained in:
就眠儀式 2022-10-23 15:03:34 +08:00
parent 2a8000758f
commit e4e6bd0f84
2 changed files with 5 additions and 3 deletions

View File

@ -58,12 +58,14 @@ watch(
const totalPage = computed(() => {
maxPage.value = Math.ceil(props.total / inlimit.value);
let r: number[] = [];
// star
let start =
maxPage.value <= props.pages
? 1
: currentPage.value > pages
? currentPage.value - pages
? maxPage.value - currentPage.value + 1 < pages ? currentPage.value - (pages + (pages - (maxPage.value - currentPage.value + 1))) : currentPage.value - pages
: 1;
for (let i = start; ; i++) {
if (r.length >= props.pages || i > maxPage.value) {
break;

View File

@ -111,7 +111,7 @@ export default {
setup() {
const limit3 = ref(5)
const total3 = ref(100)
const total3 = ref(125)
const limits3 = ref([5, 10, 50, 100, 200])
return {
@ -181,7 +181,7 @@ export default {
const limit5 = ref(10)
const total5 = ref(99)
const pages5 = ref(6);
const pages5 = ref(7);
const current5 = ref(1);
const changeCurrent5 = () => {
current5.value = 2;