HarmonyOS 使用Navigation的一些疑问

Navigation一般是作为首页, NavDestination作为二级页面。

1.NavDestination的子组件, 是否可以使用@Entry ?

2.NavDestination的子组件可以正常使用LocalStorage吗? NavDestination的子组件属于二级页面吗? 页面级别的?

HarmonyOS
2024-10-18 11:08:34
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zxjiu

1、NavDestination的子组件不使用@Entry。

2、NavDestination的子组件是二级页面。如何关联LocalStorage,请参考代码:

let para: Record<string, number> = { 'PropA': 47 };  
let storage: LocalStorage = new LocalStorage(para);  
@Component  
export struct PageOneTmp {  
  @Consume('pageInfos') pageInfos: NavPathStack;  
  @State areaCodeSelectViewIsPresent: boolean = false  
  build() {  
    NavDestination() {  
      Column() {  
        Text('新页面')  
      }  
    }  
    .title('pageOne')  
    .hideTitleBar(false)  
  }  
}  
@Entry({ storage: storage })  
@Component  
struct navLocalStrogePage {  
  @Provide('pageInfos') pageInfos: NavPathStack = new NavPathStack()  
  @State topSafeHeight: number = 0  
  private count: number = 49;  
  @Builder  
  PageMap(name: string) {  
    if (name === 'pageOne') {  
      PageOneTmp()  
    }  
  }  
  build() {  
    Navigation(this.pageInfos) {  
      Column() {  
        Button('pushPath')  
          .onClick(() => {  
            this.pageInfos.pushPath({ name: 'pageOne' })  
  
            let link1: SubscribedAbstractProperty<number> = storage.setAndLink('PropB', this.count); // Create PropB 49  
            console.log("link1::"+link1.get());  
            let link2: SubscribedAbstractProperty<number> = storage.setAndLink('PropA', this.count); // PropA exists, remains 47  
            console.log("link2::"+link2.get());  
            this.count++;  
           console.log("count::"+this.count);  
          })  
      }  
    }  
    .navDestination(this.PageMap)  
  }  
}
  • 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.
  • 46.
  • 47.
分享
微博
QQ
微信
回复
2024-10-18 18:37:12
相关问题
HarmonyOS 关于RdbStore操作一些疑问
898浏览 • 1回复 待解决
HarmonyOS Navigation转场动画一些思路
679浏览 • 1回复 待解决
HarmonyOS 关于VPN一些使用问题?
2813浏览 • 1回复 待解决
docker 线上使用一些问题
3271浏览 • 1回复 待解决
关于designWidth一些问题
1159浏览 • 1回复 待解决
关于liteos,有一些疑惑
9875浏览 • 3回复 待解决
HarmonyOS 是否支持指定一些字体?
867浏览 • 1回复 待解决
HarmonyOS hiAppEvent一些相关问题咨询
642浏览 • 1回复 待解决
HarmonyOS 有关Video组件一些问题
904浏览 • 1回复 待解决
关于系统信息一些参数询问
1137浏览 • 1回复 待解决
一些帐号授权相关问题
9524浏览 • 2回复 待解决
关于快速修复一些问题。
1445浏览 • 1回复 待解决
关于鸿蒙BLE一些问题
5072浏览 • 1回复 待解决
HUAWEI DevEco Device Tool一些问题
9460浏览 • 3回复 待解决
关于华为应用级AT一些问题
12828浏览 • 3回复 待解决
DevEco Studio 升级后一些问题
10955浏览 • 1回复 待解决
HarmonyOS 咨询下Tab中一些写法
890浏览 • 1回复 待解决
有没有新napi一些demo?
968浏览 • 3回复 待解决
如何获取一些应用开发必要信息
1082浏览 • 1回复 待解决