修改页数到达临界值时样式,增加提示
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
ref,
|
ref,
|
||||||
watch
|
watch
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
|
import infoBox from '@/commons/utils/infoBox.js'
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
size: {
|
size: {
|
||||||
type: Number,
|
type: Number,
|
||||||
@@ -51,7 +52,7 @@
|
|||||||
default: 0
|
default: 0
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const emits = defineEmits(['change'])
|
const emits = defineEmits(['change','update:page'])
|
||||||
|
|
||||||
let currentPage = ref(props.page === 0 ? 1 : props.page)
|
let currentPage = ref(props.page === 0 ? 1 : props.page)
|
||||||
|
|
||||||
@@ -81,16 +82,17 @@
|
|||||||
function btnClick(isAdd) {
|
function btnClick(isAdd) {
|
||||||
let newPage = currentPage.value * 1 + (isAdd == 'add' ? 1 : -1)
|
let newPage = currentPage.value * 1 + (isAdd == 'add' ? 1 : -1)
|
||||||
if (newPage <= 0) {
|
if (newPage <= 0) {
|
||||||
return
|
return infoBox.showToast('已经是第一页了')
|
||||||
}
|
}
|
||||||
if (newPage > maxPage.value) {
|
if (newPage > maxPage.value) {
|
||||||
return
|
return infoBox.showToast('没有更多页了')
|
||||||
}
|
}
|
||||||
setCurrentPage(newPage)
|
setCurrentPage(newPage)
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(() => currentPage.value, (newval) => {
|
watch(() => currentPage.value, (newval) => {
|
||||||
emits('change', newval)
|
emits('change', newval)
|
||||||
|
emits('update:page', newval)
|
||||||
defaultPaageIndex.value = newval - 1
|
defaultPaageIndex.value = newval - 1
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@@ -122,8 +124,8 @@
|
|||||||
|
|
||||||
.prve,.next {
|
.prve,.next {
|
||||||
&.disabled {
|
&.disabled {
|
||||||
background-color: #ccc;
|
// background-color: #ccc;
|
||||||
border-color: #ccc;
|
// border-color: #ccc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user