|
@@ -11,6 +11,9 @@ export struct RefreshView {
|
|
|
init: boolean = true
|
|
init: boolean = true
|
|
|
// 第一次加载完成,是否定位到底部,默认`false`,定位到顶部
|
|
// 第一次加载完成,是否定位到底部,默认`false`,定位到顶部
|
|
|
positioningToBottom: boolean = false
|
|
positioningToBottom: boolean = false
|
|
|
|
|
+ // 自动计算是否加载更多,默认`default`。如果data的数据量可以被pageSize整除,则触发加载更多
|
|
|
|
|
+ // 'allow' 触发loadMore, ’not' 不触发loadMore
|
|
|
|
|
+ @Prop canLoadMore: 'default' | 'allow' | 'not' = 'default'
|
|
|
pageSize: number = 10
|
|
pageSize: number = 10
|
|
|
onLoadMore?: (pageNum: number) => void
|
|
onLoadMore?: (pageNum: number) => void
|
|
|
onRefresh?: () => void
|
|
onRefresh?: () => void
|
|
@@ -148,7 +151,7 @@ export struct RefreshView {
|
|
|
this.endY = e1.y
|
|
this.endY = e1.y
|
|
|
if (this.endY - this.startY < -100 && this._openMore) {
|
|
if (this.endY - this.startY < -100 && this._openMore) {
|
|
|
const v = this.data && (this.data.length % this.pageSize) === 0
|
|
const v = this.data && (this.data.length % this.pageSize) === 0
|
|
|
- if (v) {
|
|
|
|
|
|
|
+ if ((v && this.canLoadMore == 'default') || this.canLoadMore == 'allow') {
|
|
|
const cTime = new Date().getTime()
|
|
const cTime = new Date().getTime()
|
|
|
// 2024.11.21 测试觉得刷新太多了,暂时改为1秒5间隔
|
|
// 2024.11.21 测试觉得刷新太多了,暂时改为1秒5间隔
|
|
|
if (cTime - this._oTime > 1500) {
|
|
if (cTime - this._oTime > 1500) {
|