openharmony 鸿蒙 arkts-application-state-management-overview

2025-06-12 浏览 (1)

Application State Management Overview

The decorators described in the previous topics are used to share state variables within a page, that is, within a component tree. If you want to share state data at the application level or across multiple pages, you would need to apply application-level state management. ArkTS provides a wide variety of application state management capabilities:

  • LocalStorage: API for storing the UI state, usually used for state sharing within a UIAbility or between pages.

  • AppStorage: special, singleton LocalStorage object within the application, which is created by the UI framework at application startup and provides the central storage for application UI state attributes.

  • PersistentStorage: API for persisting application attributes. It is usually used together with AppStorage to persist selected AppStorage attributes to the disk so that their values are the same upon application re-start as they were when the application was closed.

  • Environment: a range of environment parameters regarding the device where the application runs. The environment parameters are synchronized to AppStorage and can be used together with AppStorage.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙@AnimatableExtend Decorator: Definition of Animatable Attributes

harmony 鸿蒙AppStorage: Storing Application-wide UI State

harmony 鸿蒙Basic Syntax Overview

harmony 鸿蒙@Builder Decorator: Custom Builder Function

harmony 鸿蒙@BuilderParam Decorator: Referencing the @Builder Function

harmony 鸿蒙Creating a Custom Component

harmony 鸿蒙Mixing Use of Custom Components

harmony 鸿蒙Constraints on Access Modifiers of Custom Component Member Variables

harmony 鸿蒙Freezing a Custom Component

harmony 鸿蒙Freezing a Custom Component

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/jr5uIa