在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' })