当前位置:   article > 正文

鸿蒙 使用 Refresh 实现下拉刷新_鸿蒙 refresh 手动刷新

鸿蒙 refresh 手动刷新

  1. import promptAction from '@ohos.promptAction'
  2. @Entry
  3. @Component
  4. struct Index {
  5. @State
  6. refreshing: boolean = false
  7. @State
  8. list: number[] = Array(20).fill(Date.now())
  9. @Builder
  10. content(){
  11. Stack(){
  12. Row(){
  13. LoadingProgress()
  14. .height(32)
  15. Text('正在刷新...')
  16. .fontSize(16)
  17. .margin({left:20})
  18. }
  19. .alignItems(VerticalAlign.Center)
  20. }
  21. .align(Alignment.Center)
  22. }
  23. build() {
  24. Column(){
  25. Refresh({ refreshing: $$this.refreshing, builder: this.content() }){
  26. List(){
  27. ForEach(this.list, (item: string)=>{
  28. ListItem(){
  29. Row(){
  30. Text(item.toString())
  31. }
  32. .justifyContent(FlexAlign.Center)
  33. .width('100%')
  34. .padding(20)
  35. }
  36. })
  37. }
  38. .divider({
  39. strokeWidth: 1,
  40. color: Color.Yellow,
  41. startMargin: 10,
  42. endMargin: 10
  43. })
  44. }
  45. .onRefreshing(()=>{
  46. setTimeout(()=>{
  47. this.list = Array(20).fill(Date.now())
  48. this.refreshing = false
  49. promptAction.showToast({message:'刷新成功'})
  50. },1000)
  51. })
  52. }
  53. .height('100%')
  54. .width('100%')
  55. }
  56. }

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/运维做开发/article/detail/1008993
推荐阅读
相关标签
  

闽ICP备14008679号