🐛(component): 修复 total 为 0 时禁用下一页操作

This commit is contained in:
就眠儀式 2022-08-23 23:11:23 +08:00
parent fccdf27ae2
commit df8b318bdc
2 changed files with 5 additions and 4 deletions

View File

@ -84,7 +84,7 @@ const prev = () => {
}; };
const next = () => { const next = () => {
if (currentPage.value === maxPage.value) { if (currentPage.value === maxPage.value || maxPage.value === 0) {
return; return;
} }
currentPage.value++; currentPage.value++;
@ -133,6 +133,7 @@ watch(
</script> </script>
<template> <template>
{{ maxPage }}
<div class="layui-laypage layui-laypage-default"> <div class="layui-laypage layui-laypage-default">
<span v-if="showCount" class="layui-laypage-count" <span v-if="showCount" class="layui-laypage-count"
> {{ total }} {{ maxPage }} </span > {{ total }} {{ maxPage }} </span
@ -171,8 +172,8 @@ watch(
href="javascript:;" href="javascript:;"
class="layui-laypage-next" class="layui-laypage-next"
:class="[ :class="[
currentPage === maxPage ? 'layui-disabled' : '', currentPage === maxPage || maxPage === 0 ? 'layui-disabled' : '',
theme && currentPage !== maxPage ? 'layui-laypage-a-' + theme : '', theme && (currentPage !== maxPage && maxPage !== 0) ? 'layui-laypage-a-' + theme : '',
]" ]"
@click="next()" @click="next()"
> >

View File

@ -143,7 +143,7 @@ export default {
setup() { setup() {
const limit4 = ref(20) const limit4 = ref(20)
const total4 = ref(100) const total4 = ref(0)
const change4 = ({ current, limit }) => { const change4 = ({ current, limit }) => {
layer.msg("current:" + current + " limit:" + limit); layer.msg("current:" + current + " limit:" + limit);
} }