HarmonyOS 基于Navigation的路由管理替换Router首页偶现异常动画

Navigation替换router,使用Navigation容器包裹原有实现,首页打开存在偶现左上角扩展开的动画效果,10-20%的复现概率。

伪代码:

Navigation(this.pageStack) {  
    Column() {  
      pageone();  
    }  
  }  
pageone:  
  NavDestination() {  
    Column() {  
    }  
  }  
aboutToAppear(): void {  
       this.pageStack.clear();  
    this.pageStack.replacePathByName('HomePage', false);  
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
HarmonyOS
2024-10-14 10:04:48
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
put_get

可以参考如下demo:

@Entry  
@Component  
struct Index {  
  @Provide('pageInfo') pageInfo: NavPathStack = new NavPathStack()  
  @State message: string = '做一个简单的测试'  
  @Builder  
  PageMap(name: string) {  
    if (name === 'pageTwo') {  
      pageTwoTmp({ names: name, values: this.pageInfo } as Pages)  
    } else if (name === `dialog`) {  
       }  
  }  
  build() {  
    Navigation(this.pageInfo) {  
      Column() {  
        Text(this.message)  
        Button('打开pageTwo', { stateEffect: true, type: ButtonType.Capsule })  
          .width('80%')  
          .height(40)  
          .margin(10)  
          .onClick(() => {  
            this.pageInfo.pushPathByName('pageTwo', undefined);  
          })  
      }  
    }.title('NavIndex').navDestination(this.PageMap)  
  }  
}  
  
// PageTwo.ets  
export class Pages {  
  names: string = ""  
  values: NavPathStack | null = null  
}  
@Builder  
export function pageTwoTmp(info: Pages) {  
  NavDestination() {  
    Column() {  
      Text("测试")  
    }.width('100%').height('100%')  
  }.title('pageTwo')  
  .onBackPressed(() => {  
    (info.values as NavPathStack).pop();  
    return true;  
  })  
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
分享
微博
QQ
微信
回复
2024-10-14 17:43:01
相关问题
router.back调用时,app自动退出
2368浏览 • 1回复 待解决
HarmonyOS router路由管理
635浏览 • 1回复 待解决
HarmonyOS 接口返回空字段
571浏览 • 1回复 待解决
路由导航用router还是navigation
366浏览 • 1回复 待解决
HarmonyOS media.AVPlayer报错
798浏览 • 1回复 待解决
HarmonyOS app图标显示错误
909浏览 • 1回复 待解决
HarmonyOS 视频播放 5400106 错误码
853浏览 • 1回复 待解决
HarmonyOS 在entry里替换首页
867浏览 • 1回复 待解决
HarmonyOS ArkTS调C++ 方法找不到。
1372浏览 • 1回复 待解决
HarmonyOS 首页下拉刷新异常
1008浏览 • 1回复 待解决
HarmonyOS router路由路径问题
1148浏览 • 1回复 待解决