[修复]LayPage页码起止范围计算问题
This commit is contained in:
parent
32b30edff1
commit
e50ef83e83
@ -129,7 +129,7 @@ export default {
|
|||||||
::: demo
|
::: demo
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<lay-page :limit="limit" :total="total" :limits="[10,50,100,200]"></lay-page>
|
<lay-page :limit="limit" :total="total" showCount showPage :limits="[10,50,100,200]" @limit="limit=$event"></lay-page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -157,7 +157,7 @@ export default {
|
|||||||
::: demo
|
::: demo
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<lay-page :limit="limit" :total="total" @limit="limit=$event" :show-limit="showLimit" ></lay-page>
|
<lay-page :limit="limit" showPage showCount :total="total" @limit="limit=$event" :show-limit="showLimit" ></lay-page>
|
||||||
<div>每页数量:{{limit}}</div>
|
<div>每页数量:{{limit}}</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -87,15 +87,11 @@ const pages = props.pages / 2
|
|||||||
const inlimit = computed({ get() { return props.limit }, set(v: number) { emit('limit', v) } })
|
const inlimit = computed({ get() { return props.limit }, set(v: number) { emit('limit', v) } })
|
||||||
const maxPage = ref(Math.ceil(props.total / props.limit));
|
const maxPage = ref(Math.ceil(props.total / props.limit));
|
||||||
const totalPage = computed(() => {
|
const totalPage = computed(() => {
|
||||||
let r: number[] = [], end = maxPage.value
|
let r: number[] = [], start = (maxPage.value <= props.pages ? 1 : currentPage.value > pages ? currentPage.value - pages : 1)
|
||||||
if (currentPage.value <= pages) {
|
for (let i = start; ; i++) {
|
||||||
end = props.pages + 1
|
if (r.length >= props.pages || i > maxPage.value) {
|
||||||
} else if (currentPage.value + pages > end) {
|
break;
|
||||||
|
}
|
||||||
} else {
|
|
||||||
end = currentPage.value + pages
|
|
||||||
}
|
|
||||||
for (let i = currentPage.value > pages ? currentPage.value - pages : 1; i < end; i++) {
|
|
||||||
r.push(i)
|
r.push(i)
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
|
Loading…
Reference in New Issue
Block a user