在HarmonyOS NEXT开发中Navigation 的页面路由用法 NavPathStack 的 pushPath 方法的name参数在什么地方配置?

在HarmonyOS NEXT开发中Navigation 的页面路由用法 NavPathStack 的 pushPath 方法的name参数在什么地方配置?

阅读 1.3k
2 个回答

参考如下demo:
@Entry
@Component
struct NavigationExample {
pageInfos: NavPathStack = new NavPathStack()
build() {

Navigation(this.pageInfos) {
  Column() {
    Button('pushPath', { stateEffect: true, type: ButtonType.Capsule })
      .width('80%')
      .height(40)
      .margin(20)
      .onClick(() => {
        this.pageInfos.pushPath({ name: 'pageOne' }) //将name指定的NavDestination页面信息入栈
      })
    Button('use interception', { stateEffect: true, type: ButtonType.Capsule })
      .width('80%')
      .height(40)
      .margin(20)
      .onClick(() => {
        this.isUseInterception = !this.isUseInterception;
        if (this.isUseInterception) {
          this.registerInterception();
        } else {
          this.pageInfos.setInterception(undefined);
        }
      })
  }
}.title('NavIndex')

}
}

Navigation 的页面路由用法 NavPathStack 的 pushPath 方法的name参数如下配置:
this.pageInfos.pushPath({ name: 'pageOne' })

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进