fix(pagination): 🐛 修复watch监听props.total导致的TypeScript类型错误

closed #IBJY7R
This commit is contained in:
Ray.Hao
2025-02-02 23:12:00 +08:00
parent 2d31f354cb
commit 49317acee7

View File

@@ -53,6 +53,7 @@ const currentPage = defineModel("page", {
required: true,
default: 1,
});
const pageSize = defineModel("limit", {
type: Number,
required: true,
@@ -60,18 +61,18 @@ const pageSize = defineModel("limit", {
});
watch(
props.total,
() => props.total,
(newVal: number) => {
const lastPage = Math.ceil(newVal / pageSize.value)
const lastPage = Math.ceil(newVal / pageSize.value);
if (newVal > 0 && currentPage.value > lastPage) {
currentPage.value = lastPage
currentPage.value = lastPage;
emit("pagination", { page: currentPage.value, limit: pageSize.value });
}
}
);
function handleSizeChange(val: number) {
currentPage.value = 1
currentPage.value = 1;
emit("pagination", { page: currentPage.value, limit: val });
}