1e41f4b71Sopenharmony_ci# StartAbilityParameter 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci定义启动Ability参数,可以作为入参,调用[startAbility](js-apis-ability-featureAbility.md#featureabilitystartability)启动指定的Ability。 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **说明:** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> 本接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 8e41f4b71Sopenharmony_ci> 本接口仅可在FA模型下使用 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci## 导入模块 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci```ts 13e41f4b71Sopenharmony_ciimport ability from '@ohos.ability.ability'; 14e41f4b71Sopenharmony_ci``` 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci## 属性 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.FAModel 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci| 名称 | 类型 | 必填 | 说明 | 21e41f4b71Sopenharmony_ci| ------------------- | -------- | ---- | -------------------------------------- | 22e41f4b71Sopenharmony_ci| want | [Want](js-apis-app-ability-want.md)| 是 | 启动Ability的want信息。 | 23e41f4b71Sopenharmony_ci| abilityStartSetting | { [key: string]: any } | 否 | 启动Ability的特殊属性,当开发者启动Ability时,该属性可以作为调用中的输入参数传递。 | 24e41f4b71Sopenharmony_ci| abilityStartSettings<sup>11+<sup> | Record\<string, Object> | 否 | 启动Ability的特殊属性,当开发者启动Ability时,该属性可以作为调用中的输入参数传递。推荐使用该属性替代abilityStartSetting,设置该属性后,abilityStartSetting不再生效。 | 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci**示例:** 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ci<!--code_no_check_fa--> 29e41f4b71Sopenharmony_ci```ts 30e41f4b71Sopenharmony_ciimport ability from '@ohos.ability.ability'; 31e41f4b71Sopenharmony_ciimport featureAbility from '@ohos.ability.featureAbility'; 32e41f4b71Sopenharmony_ciimport Want from '@ohos.app.ability.Want'; 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_cilet want: Want = { 35e41f4b71Sopenharmony_ci bundleName: 'com.example.abilityStartSettingApp2', 36e41f4b71Sopenharmony_ci abilityName: 'com.example.abilityStartSettingApp.EntryAbility', 37e41f4b71Sopenharmony_ci}; 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_cilet startAbilityParameter: ability.StartAbilityParameter = { 40e41f4b71Sopenharmony_ci want : want, 41e41f4b71Sopenharmony_ci abilityStartSettings : { 42e41f4b71Sopenharmony_ci abilityBounds : [100,200,300,400], 43e41f4b71Sopenharmony_ci windowMode : 44e41f4b71Sopenharmony_ci featureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED, 45e41f4b71Sopenharmony_ci displayId : 1, 46e41f4b71Sopenharmony_ci } 47e41f4b71Sopenharmony_ci}; 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_citry { 50e41f4b71Sopenharmony_ci featureAbility.startAbility(startAbilityParameter, (error, data) => { 51e41f4b71Sopenharmony_ci if (error && error.code !== 0) { 52e41f4b71Sopenharmony_ci console.error(`startAbility fail, error: ${JSON.stringify(error)}`); 53e41f4b71Sopenharmony_ci } else { 54e41f4b71Sopenharmony_ci console.log(`startAbility success, data: ${JSON.stringify(data)}`); 55e41f4b71Sopenharmony_ci } 56e41f4b71Sopenharmony_ci }); 57e41f4b71Sopenharmony_ci} catch(error) { 58e41f4b71Sopenharmony_ci console.error(`startAbility error: ${JSON.stringify(error)}`); 59e41f4b71Sopenharmony_ci} 60e41f4b71Sopenharmony_ci```