HarmonyOS navigation跳转参数获取

HarmonyOS
2024-12-26 14:23:00
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zxjiu

方式1:

build() {
  NavDestination() {
    Column() {
      Text("PageOne组件")
        .fontSize(50)
        .fontWeight(FontWeight.Bold)
      ...
    }
    // .mode(NavDestinationMode.DIALOG)
    .title("PageOne组件")
    .onReady((context: NavDestinationContext) => {
      this.pageInfos = context.pathStack
      console.log('param=', JSON.stringify(context.pathInfo.param))
    })
  }
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.

方式2:

aboutToAppear(): void {
  console.log('size param=', this.pageInfos.size())
  console.log('about param=', this.pageInfos.getParamByIndex(this.pageInfos.size() - 1))
  console.log('about param=', this.pageInfos.getParamByName("PageOne"))
  this.registerInterception();
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.

方式1验证可行,方式2需要在开发者的场景下验证下是否可行

分享
微博
QQ
微信
回复
2024-12-26 17:30:36


相关问题
HarmonyOS router跳转navigation跳转
737浏览 • 1回复 待解决
HarmonyOS 100005 Navigation跳转失败
539浏览 • 1回复 待解决
HarmonyOS Navigation动态跳转页面问题
804浏览 • 1回复 待解决
HarmonyOS 路由跳转怎么接收参数
892浏览 • 1回复 待解决
Navigation页面跳转的问题
1337浏览 • 1回复 待解决
如何使用Navigation的navPathStack参数
2584浏览 • 1回复 待解决
HarmonyOS Navigation跳转的组件生命周期
1861浏览 • 2回复 待解决
HarmonyOS Navigation跳转生命周期咨询
1215浏览 • 1回复 待解决
HarmonyOS navigation跳转页面为空白页
782浏览 • 1回复 待解决