1e41f4b71Sopenharmony_ci# @ohos.app.ability.StartOptions (StartOptions)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciStartOptions可以作为[startAbility()](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability-1)的入参,用于指定目标Ability的窗口模式。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **说明:**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> - 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci> - 本模块接口仅可在Stage模型下使用。
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci## 导入模块
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci```ts
14e41f4b71Sopenharmony_ciimport { StartOptions } from '@kit.AbilityKit';
15e41f4b71Sopenharmony_ci```
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci## 属性
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci| 名称 | 类型 | 只读 | 可选 | 说明 |
22e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
23e41f4b71Sopenharmony_ci| windowMode<sup>12+<sup> | number | 否 | 是 | 启动Ability时的窗口模式,详见[WindowMode](./js-apis-app-ability-abilityConstant.md#windowmode12)。 |
24e41f4b71Sopenharmony_ci| displayId | number | 否 | 是 | 屏幕ID模式。默认是0,表示当前屏幕。<br>**原子化服务API:** 从API version 11开始,该接口支持在原子化服务中使用。 |
25e41f4b71Sopenharmony_ci| withAnimation<sup>11+</sup> | boolean | 否 | 是 | Ability是否具有动画效果。 |
26e41f4b71Sopenharmony_ci| windowLeft<sup>11+</sup> | number | 否 | 是 | 窗口左边的位置。 |
27e41f4b71Sopenharmony_ci| windowTop<sup>11+</sup> | number | 否 | 是 | 窗口顶部的位置。 |
28e41f4b71Sopenharmony_ci| windowWidth<sup>11+</sup> | number | 否 | 是 | 窗口的宽度。 |
29e41f4b71Sopenharmony_ci| windowHeight<sup>11+</sup> | number | 否 | 是 | 窗口的高度。 |
30e41f4b71Sopenharmony_ci| processMode<sup>12+</sup> | [contextConstant.ProcessMode](js-apis-app-ability-contextConstant.md#processmode12) | 否 | 是 | 进程模式。<br>**约束:**<br>1.仅在平板类设备上生效。<br>2.仅在[UIAbilityContext.startAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability-1)中生效。<br>3.processMode和startupVisibility必须同时设置。 |
31e41f4b71Sopenharmony_ci| startupVisibility<sup>12+</sup> | [contextConstant.StartupVisibility](js-apis-app-ability-contextConstant.md#startupvisibility12) | 是 | 否 | Ability启动后的可见性。<br>**约束:**<br>1.仅在平板类设备上生效。<br>2.仅在[UIAbilityContext.startAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability-1)中生效。<br>3.processMode和startupVisibility必须同时设置。 |
32e41f4b71Sopenharmony_ci| startWindowIcon<sup>14+</sup> | [image.PixelMap](../../reference/apis-image-kit/js-apis-image.md#pixelmap7) | 否 | 是 |  在应用内启动UIAbility时,启动页所显示的图标。如果未配置该字段,则默认采用module.json5文件中startWindowIcon字段的配置。<br>**约束:**<br>1.仅在平板与2in1设备上生效。<br>2.仅在[UIAbilityContext.startAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability-1)中生效。<br>3.图片数据大小限制为600M。|
33e41f4b71Sopenharmony_ci| startWindowBackgroundColor<sup>14+</sup> | string | 否 | 是 |  在应用内启动UIAbility时,启动页所显示的背景颜色。如果未配置该字段,则默认采用module.json5文件中startWindowBackground字段的配置。<br>**约束:**<br>1.仅在平板与2in1设备上生效。<br>2.仅在[UIAbilityContext.startAbility](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartability-1)中生效。 |
34e41f4b71Sopenharmony_ci 
35e41f4b71Sopenharmony_ci**示例:**
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci  ```ts
38e41f4b71Sopenharmony_ci  import { UIAbility, Want, StartOptions } from '@kit.AbilityKit';
39e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
40e41f4b71Sopenharmony_ci  import { image } from '@kit.ImageKit';
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci  export default class EntryAbility extends UIAbility {
43e41f4b71Sopenharmony_ci    onForeground() {
44e41f4b71Sopenharmony_ci      let want: Want = {
45e41f4b71Sopenharmony_ci        deviceId: '',
46e41f4b71Sopenharmony_ci        bundleName: 'com.example.myapplication',
47e41f4b71Sopenharmony_ci        abilityName: 'EntryAbility'
48e41f4b71Sopenharmony_ci      };
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci      let color = new ArrayBuffer(0);
51e41f4b71Sopenharmony_ci      let imagePixelMap: image.PixelMap;
52e41f4b71Sopenharmony_ci      image.createPixelMap(color, {
53e41f4b71Sopenharmony_ci        size: {
54e41f4b71Sopenharmony_ci          height: 100,
55e41f4b71Sopenharmony_ci          width: 100
56e41f4b71Sopenharmony_ci        }
57e41f4b71Sopenharmony_ci      }).then((data) => {
58e41f4b71Sopenharmony_ci        imagePixelMap = data;
59e41f4b71Sopenharmony_ci        let options: StartOptions = {
60e41f4b71Sopenharmony_ci          displayId: 0,
61e41f4b71Sopenharmony_ci          startWindowIcon: imagePixelMap,
62e41f4b71Sopenharmony_ci          startWindowBackgroundColor: '#00000000'
63e41f4b71Sopenharmony_ci        };
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci        try {
66e41f4b71Sopenharmony_ci          this.context.startAbility(want, options, (err: BusinessError) => {
67e41f4b71Sopenharmony_ci            if (err.code) {
68e41f4b71Sopenharmony_ci              // 处理业务逻辑错误
69e41f4b71Sopenharmony_ci              console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
70e41f4b71Sopenharmony_ci              return;
71e41f4b71Sopenharmony_ci            }
72e41f4b71Sopenharmony_ci            // 执行正常业务
73e41f4b71Sopenharmony_ci            console.info('startAbility succeed');
74e41f4b71Sopenharmony_ci          });
75e41f4b71Sopenharmony_ci        } catch (err) {
76e41f4b71Sopenharmony_ci          // 处理入参错误异常
77e41f4b71Sopenharmony_ci          let code = (err as BusinessError).code;
78e41f4b71Sopenharmony_ci          let message = (err as BusinessError).message;
79e41f4b71Sopenharmony_ci          console.error(`startAbility failed, code is ${code}, message is ${message}`);
80e41f4b71Sopenharmony_ci        }
81e41f4b71Sopenharmony_ci      }).catch((err: BusinessError) => {
82e41f4b71Sopenharmony_ci        console.error(`createPixelMap failed, code is ${err.code}, message is ${err.message}`);
83e41f4b71Sopenharmony_ci      });
84e41f4b71Sopenharmony_ci    }
85e41f4b71Sopenharmony_ci  }
86e41f4b71Sopenharmony_ci  ```
87