已关闭
[Bug]: 在 Navigation 的 NavDestination 中使用 PullToRefreshV2 ,会导致 onRefresh 调用两次 #151
甚是丶搞笑创建于  2025年7月29日关闭于  7 天前
甚是丶搞笑
甚是丶搞笑
2025年7月29日 创建

感谢对OpenHarmony社区的支持与关注,欢迎反馈缺陷。

发生了什么问题?

版本:2.1.2
1.使用navigation 组件中 通过 NavPathStack.push 启动 一个 NavDestination 页面 ( .hideTitleBar(true) )
2.在 NavDestination 页面中使用 PullToRefreshV2 组件,下拉达到可触发刷新状态后松手,会百分百触发两次下拉刷新

期望行为是什么?

下拉刷新只触发一次

如何复现该缺陷

如问题描述

库的版本或分支信息

如问题描述

当前使用的DevEco Studio 和 Openharmony/HarmonyOS SDK的版本信息

模拟器 : API 16
dev版本::DevEco Studio 5.0.5 Release

其他补充信息

likedislike
甚是丶搞笑甚是丶搞笑
2025年7月29日 添加了label:bug
Jjingjing_liujing
8月14日 关联了pull request:[Bug]: 在 Navigation 的 NavDestination 中使用 PullToRefreshV2 ,会导致 onRefresh 调用两次
jingjing_liujing
8月15日 评论:

请提供能复现的demo

以下demo下拉刷新只触发一次
import { PullToRefreshV2 } from '@ohos/pulltorefresh'

@Entry
@Component
struct NavTestPage {
navPathStack: NavPathStack = new NavPathStack()

build() {
Navigation(this.navPathStack) {
Column() {
Button('跳转到 NavDestination')
.onClick(() => {
this.navPathStack.pushPath({ name: 'TestPage' })
})
}
.width('100%')
.justifyContent(FlexAlign.Center)
}
.mode(NavigationMode.Stack)
.navDestination(this.buildNavDestination)
}

@Builder
buildNavDestination(name: string) {
if (name === 'TestPage') {
NavDestination() {
PullToRefreshV2({
data: this.navData,
scroller: this.navScroller,
customList: () => {
this.navListView()
},
onRefresh: () => {
this.navRefreshCount++
console.info([Verify] onRefresh 被调用,第 ${this.navRefreshCount} 次)
return new Promise((resolve) => {
setTimeout(() => {
resolve('刷新成功')
}, 2000)
})
},
onLoadMore: () => {
return new Promise((resolve) => {
setTimeout(() => {
resolve('')
for (let i = 0; i < 10; i++) {
this.navData.push(新增条目 ${this.navData.length})
}
}, 2000)
})
},
customRefresh: null,
customLoad: null,
})
}
.hideTitleBar(true)
}
}

private navData: string[] = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
private navScroller: Scroller = new Scroller()
private navRefreshCount: number = 0

@Builder
navListView() {
List({ space: 20, scroller: this.navScroller }) {
ForEach(this.navData, (item: string) => {
ListItem() {
Text(item)
.width('100%')
.height(150)
.fontSize(20)
.textAlign(TextAlign.Center)
.backgroundColor('#95efd2')
}
})
}
.backgroundColor('#eeeeee')
.divider({ strokeWidth: 1, color: 0x222222 })
.edgeEffect(EdgeEffect.None)
}
}

【温馨提示】为了更高效地推进问题闭环,请您在 两周内(14 天)对此留言做出回应。若逾期未收到回复,我们将关闭此 Issue,并备注“长时间未回复而自动关闭”。关闭后您仍可以随时补充信息并重新开启,我们会继续跟进。感谢理解!

likedislike
wxxxx
wxxxx成员
7 天前 评论:

pr 已完成/关闭,issue 同步完成

likedislike
wxxxxwxxxx成员
7 天前 关闭了 issue
wxxxxwxxxx成员
7 天前 issue状态由 待办的 改变为 已完成