Refresh
可以進(jìn)行頁面下拉操作并顯示刷新動效的容器組件。
說明:
開發(fā)前請熟悉鴻蒙開發(fā)指導(dǎo)文檔 :[gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md]
該組件從API Version 8開始支持。后續(xù)版本如有新增內(nèi)容,則采用上角標(biāo)單獨(dú)標(biāo)記該內(nèi)容的起始版本。當(dāng)設(shè)置自定義組件時,自定義組件的高度限制在64vp之內(nèi)。
子組件
支持單個子組件。
接口
Refresh(value: { refreshing: boolean, offset?: number | string , friction?: number | string, builder?: Custombuilder})
參數(shù):
| 參數(shù) | 參數(shù)名 | 必填 | 參數(shù)描述 |
|---|---|---|---|
| refreshing | boolean | 是 | 當(dāng)前組件是否正在刷新。 該參數(shù)支持[$$]雙向綁定變量。 |
| offset | string | number | 否 |
| friction | number | string | 否 |
| builder | [CustomBuilder]10+ | 否 | 下拉時,自定義刷新樣式的組件。 |
屬性
支持[通用屬性]。
事件
除支持[通用事件]外,還支持以下事件:
| 名稱 | 描述 |
|---|---|
| onStateChange(callback: (state: [RefreshStatus]) => void) | 當(dāng)前刷新狀態(tài)變更時,觸發(fā)回調(diào)。 - state:刷新狀態(tài)。 |
| onRefreshing(callback: () => void) | 進(jìn)入刷新狀態(tài)時觸發(fā)回調(diào)。HarmonyOS與OpenHarmony鴻蒙文檔籽料:mau123789是v直接拿 |
RefreshStatus枚舉說明
| 名稱 | 描述 |
|---|---|
| Inactive | 默認(rèn)未下拉狀態(tài)。 |
| Drag | 下拉中,下拉距離小于刷新距離。 |
| OverDrag | 下拉中,下拉距離超過刷新距離。 |
| Refresh | 下拉結(jié)束,回彈至刷新距離,進(jìn)入刷新狀態(tài)。 |
| Done | 刷新結(jié)束,返回初始狀態(tài)(頂部)。 |
示例
// xxx.ets
@Entry
@Component
struct RefreshExample {
@State isRefreshing: boolean = false
@State counter: number = 0
build() {
Column() {
Refresh({ refreshing: $$this.isRefreshing, offset: 120, friction: 100 }) {
Text('Pull Down and refresh: ' + this.counter)
.fontSize(30)
.margin(10)
}
.onStateChange((refreshStatus: RefreshStatus) = > {
console.info('Refresh onStatueChange state is ' + refreshStatus)
})
.onRefreshing(() = > {
setTimeout(() = > {
this.counter++
this.isRefreshing = false
}, 1000)
console.log('onRefreshing test')
})
}
}
}
審核編輯 黃宇
聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。
舉報投訴
-
組件
+關(guān)注
關(guān)注
1文章
572瀏覽量
19017 -
鴻蒙
+關(guān)注
關(guān)注
60文章
2963瀏覽量
45883
發(fā)布評論請先 登錄
相關(guān)推薦
熱點(diǎn)推薦
鴻蒙ArkTS容器組件:SideBarContainer
提供側(cè)邊欄可以顯示和隱藏的側(cè)邊欄容器,通過子組件定義側(cè)邊欄和內(nèi)容區(qū),第一個子組件表示側(cè)邊欄,第二個子組件表示內(nèi)容區(qū)。
鴻蒙ArkTS容器組件:Refresh
評論