openharmony 鸿蒙 ts-env-system-property

2026-08-25 浏览 (1)

@Env: Environment Variable

NOTE

The initial APIs of this module are supported since API version 22. Newly added APIs will be marked with a superscript to indicate their earliest API version.

For details about the developer guide, see @Env Developer Guide.

@Env

Env: EnvDecorator

Atomic service API: This API can be used in atomic services since API version 22.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameTypeDescription
EnvEnvDecoratorEnvironment variable decorator.

Example

import { uiObserver } from '@kit.ArkUI';

@Entry
@Component
struct Index {
  @Env(SystemProperties.BREAK_POINT) breakpoint: uiObserver.WindowSizeLayoutBreakpointInfo;

  build() {}
}

EnvDecorator

type EnvDecorator = (value: SystemProperties) => PropertyDecorator

Defines the @Env decorator type.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since API version 22.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

NameTypeMandatoryDescription
valueSystemPropertiesYesName of the environment variable.

Return value

TypeDescription
PropertyDecoratorProperty decorator.

Error codes

For details, see Environment Variable Error Codes.

IDError Message
140000Invalid key for @Env

SystemProperties

Defines the enumerated values of the environment variable.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameValueDescription
BREAK_POINT'system.arkui.breakpoint'@Env variable parameter. You can obtain the WindowSizeLayoutBreakpointInfo instance through @Env(SystemProperties.BREAK_POINT).
When this decorator is declared in @Component or @ComponentV2, it is used to obtain the size layout breakpoint information of the window where the current custom component is located.
Atomic service API: This API can be used in atomic services since API version 22.
WINDOW_SIZE23+'system.window.size'@Env variable parameter. You can obtain the SizeInVP instance through @Env(SystemProperties.WINDOW_SIZE).
When this decorator is declared in @Component or @ComponentV2, it is used to obtain the size (in vp) of the window where the current custom component is located.
Model restriction: This API can be used only in the stage model.
WINDOW_SIZE_PX23+'system.window.size.px'@Env variable parameter. You can obtain the Size instance through @Env(SystemProperties.WINDOW_SIZE_PX).
When this decorator is declared in @Component or @ComponentV2, it is used to obtain the size (in px) of the window where the current custom component is located.
Model restriction: This API can be used only in the stage model.
WINDOW_AVOID_AREA23+'system.window.avoidarea'@Env variable parameter. You can obtain the UIEnvWindowAvoidAreaInfoVP instance through @Env(SystemProperties.WINDOW_AVOID_AREA).
When this decorator is declared in @Component or @ComponentV2, it is used to obtain the avoid area (in vp) of the window where the current custom component is located.
Model restriction: This API can be used only in the stage model.
WINDOW_AVOID_AREA_PX23+'system.window.avoidarea.px'@Env variable parameter. You can obtain the UIEnvWindowAvoidAreaInfoPX instance through @Env(SystemProperties.WINDOW_AVOID_AREA_PX).
When this decorator is declared in @Component or @ComponentV2, it is used to obtain the avoid area (in px) of the window where the current custom component is located.
Model restriction: This API can be used only in the stage model.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 ts-drawing-components-shape

openharmony 鸿蒙 ts-universal-attributes-sharp-clipping

openharmony 鸿蒙 ts-universal-attributes-toolbar

openharmony 鸿蒙 ts-container-lazyvgridlayout

openharmony 鸿蒙 ohos-arkui-advanced-FoldSplitContainer

openharmony 鸿蒙 ts-methods-calendarpicker-dialog

openharmony 鸿蒙 ts-uicommonevent

openharmony 鸿蒙 ts-basic-gestures-tapgesture

openharmony 鸿蒙 ohos-arkui-advanced-DialogV2

openharmony 鸿蒙 ts-components-canvas-canvas

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