1e41f4b71Sopenharmony_ci# @ohos.app.ability.AbilityConstant (AbilityConstant)(系统接口) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci提供UIAbility中窗口类型的枚举。 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **说明:** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> 本模块接口仅可在Stage模型下使用。 10e41f4b71Sopenharmony_ci> 11e41f4b71Sopenharmony_ci> 当前页面仅包含本模块的系统接口,其他公开接口参见[@ohos.app.ability.AbilityConstant (AbilityConstant)](js-apis-app-ability-abilityConstant.md)。 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci## 导入模块 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci```ts 16e41f4b71Sopenharmony_ciimport { AbilityConstant } from '@kit.AbilityKit'; 17e41f4b71Sopenharmony_ci``` 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci## WindowMode 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci启动Ability时的窗口模式,该类型为枚举,可配合startAbility使用指定启动Ability的窗口模式。 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci**系统API**: 此接口为系统接口。 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci| 名称 | 值 | 说明 | 28e41f4b71Sopenharmony_ci| --- | --- | --- | 29e41f4b71Sopenharmony_ci| WINDOW_MODE_UNDEFINED | 0 | 未定义窗口模式。 | 30e41f4b71Sopenharmony_ci| WINDOW_MODE_FLOATING | 102 | 自由悬浮形式窗口模式。 | 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci**示例:** 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci```ts 35e41f4b71Sopenharmony_ciimport { UIAbility, StartOptions, Want, AbilityConstant } from '@kit.AbilityKit'; 36e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_cilet want: Want = { 39e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 40e41f4b71Sopenharmony_ci abilityName: 'EntryAbility' 41e41f4b71Sopenharmony_ci}; 42e41f4b71Sopenharmony_cilet option: StartOptions = { 43e41f4b71Sopenharmony_ci windowMode: AbilityConstant.WindowMode.WINDOW_MODE_FULLSCREEN 44e41f4b71Sopenharmony_ci}; 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ci// 确保从上下文获取到context 47e41f4b71Sopenharmony_ciclass MyAbility extends UIAbility { 48e41f4b71Sopenharmony_ci onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { 49e41f4b71Sopenharmony_ci this.context.startAbility(want, option).then(() => { 50e41f4b71Sopenharmony_ci console.log('Succeed to start ability.'); 51e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 52e41f4b71Sopenharmony_ci console.error('Failed to start ability with error: ${JSON.stringify(error)}'); 53e41f4b71Sopenharmony_ci }); 54e41f4b71Sopenharmony_ci } 55e41f4b71Sopenharmony_ci} 56e41f4b71Sopenharmony_ci``` 57