如何在Navigation中使用LocalStorage

如果是route的页面可以通过@Entry(storage)绑定共享数据,如果导航切换到Navigation应该怎么使用?

HarmonyOS
2024-07-23 11:09:27
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
江湖骗子嗷

LocalStorage的实例仅仅在一个@Entry装饰的组件和其所属的子组件(一个页面)中共享可以借助LocalStorage相关的两个装饰器@LocalStorageProp和@LocalStorageLink,在UI组件内部获取到LocalStorage实例中存储的状态变量。

具体API参考指南如下:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-localstorage-0000001820879593-V5

localstorageprop和localstorage单向同步的简单场景:

https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-localstorage-0000001820879593-V5#ZH-CN_TOPIC_0000001881178537__localstorageprop和localstorage单向同步的简单场景

localstoragelink和localstorage双向同步的简单场景:

https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/arkts-localstorage-0000001820879593-V5#ZH-CN_TOPIC_0000001881178537__localstoragelink和localstorage双向同步的简单场景

分享
微博
QQ
微信
回复
2024-07-23 18:34:37
相关问题
如何在C++项目中使用pthread
1549浏览 • 1回复 待解决
如何在webview中使用H5中的alert
778浏览 • 1回复 待解决
如何在hvigor自定义任务中使用npm包
628浏览 • 1回复 待解决
如何在navigation跳转页面时返回传参
920浏览 • 1回复 待解决
如何使用Navigation的navPathStack参数
622浏览 • 1回复 待解决
HarmonyOS Web组件使用localStorage报错
37浏览 • 1回复 待解决
HarmonyOS Navigation 使用问题
44浏览 • 1回复 待解决
在image组件中使用bindContextMenu报错
97浏览 • 1回复 待解决
jenkins容器中使用docker报错问题
7163浏览 • 2回复 待解决
现在如何能在onload中使用到组件的Area
1158浏览 • 0回复 待解决
Localstorage与AppStorage区别
1614浏览 • 1回复 待解决
HarmonyOS 安全控件无法在弹窗中使用
138浏览 • 1回复 待解决
hvigor自定义任务中使用npm包
416浏览 • 1回复 待解决
getContext(this)能否在自定义类中使用
1846浏览 • 1回复 待解决
在自定义组件中使用@ObjectLink报错
265浏览 • 1回复 待解决