openharmony 鸿蒙 ts-universal-entry

2026-08-25 浏览 (1)

@Entry:页面入口

@Entry装饰的自定义组件将作为UI页面的入口。

说明:

本模块首批接口从API version 7开始支持,后续版本的新增接口,采用上角标单独标记接口的起始版本。

@Entry

在单个UI页面中,仅允许存在一个由@Entry装饰的自定义组件作为页面的入口。

卡片能力: 从API version 9开始,该接口支持在ArkTS卡片中使用。

原子化服务API: 从API version 11开始,该接口支持在原子化服务中使用。

系统能力: SystemCapability.ArkUI.ArkUI.Full

示例:

// @Entry装饰的自定义组件作为UI页面的入口
@Entry
@Component
struct Index {
  build() {
    Text('@Entry Test')
  }
}

EntryOptions10+

命名路由跳转选项。

系统能力: SystemCapability.ArkUI.ArkUI.Full

名称类型只读可选说明
routeNamestring表示作为命名路由页面的名字。
卡片能力: 从API version 10开始,该接口支持在ArkTS卡片中使用。
原子化服务API: 从API version 11开始,该接口支持在原子化服务中使用。
storageLocalStorage页面级的UI状态存储。当未传入时,框架会创建一个新的LocalStorage实例作为默认值。
卡片能力: 从API version 10开始,该接口支持在ArkTS卡片中使用。
原子化服务API: 从API version 11开始,该接口支持在原子化服务中使用。
useSharedStorage12+boolean是否使用loadContent传入的LocalStorage实例对象。默认值false。true:使用共享的LocalStorage实例对象。false:不使用共享的LocalStorage实例对象。
卡片能力: 从API version 12开始,该接口支持在ArkTS卡片中使用。
原子化服务API: 从API version 12开始,该接口支持在原子化服务中使用。

示例:

// 设置路由页面名字为myPage
@Entry({ routeName: 'myPage' })
@Component
struct Index {
  build() {
    Text('Index')
  }
}

你可能感兴趣的鸿蒙文章

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/YBG9URhw