pagination修改

This commit is contained in:
lishichanglgx@163.com
2025-01-22 17:59:52 +08:00
parent 9e6727062a
commit b7043117be

View File

@@ -16,7 +16,7 @@
</template>
<script setup lang="ts">
defineProps({
const props = defineProps({
total: {
required: true,
type: Number as PropType<number>,
@@ -59,7 +59,19 @@ const pageSize = defineModel("limit", {
default: 10,
});
watch(
props.total,
(newVal: number) => {
const lastPage = Math.ceil(newVal / pageSize.value)
if (newVal > 0 && currentPage.value > lastPage) {
currentPage.value = lastPage
emit("pagination", { page: currentPage.value, limit: pageSize.value });
}
}
);
function handleSizeChange(val: number) {
currentPage.value = 1
emit("pagination", { page: currentPage.value, limit: val });
}