滑动加载组件

This commit is contained in:
chenhaizhao 2026-01-06 17:20:44 +08:00
parent 27691bd433
commit 2c402aceb7
2 changed files with 28 additions and 0 deletions

View File

@ -1,5 +1,6 @@
<script setup> <script setup>
import { onLaunch } from "@dcloudio/uni-app" import { onLaunch } from "@dcloudio/uni-app"
onLaunch(() => { onLaunch(() => {
const updateManager = wx.getUpdateManager() const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) { updateManager.onCheckForUpdate(function (res) {
@ -36,5 +37,6 @@ onLaunch(() => {
.main { .main {
min-height: 95vh; min-height: 95vh;
background: linear-gradient(to top, #f2f8ff 0%, #e7f0fd 100%); background: linear-gradient(to top, #f2f8ff 0%, #e7f0fd 100%);
padding-top: 20rpx;
} }
</style> </style>

View File

@ -0,0 +1,26 @@
<script setup>
import { ref } from "vue";
import { onReachBottom } from "@dcloudio/uni-app"
const emit = defineEmits(["reachBottom"])
//
const props = defineProps({
number: Number,
total: Number
})
let loadState = ref("loading")
//
onReachBottom(() => {
console.log(props);
if (props.number < props.total) {
loadState.value = "loading"
} else if (props.number == props.total) {
loadState.value = "finished"
}
emit("reachBottom")
})
</script>
<template>
<slot></slot>
<wd-watermark content="wot-design-uni"></wd-watermark>
<wd-loadmore :state="loadState" loading-text="数据加载中"/>
</template>