1# @ohos.app.appstartup.StartupConfig 2 3本模块提供启动任务的配置接口。 4 5> **说明:** 6> 7> 本模块首批接口从API version 12开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 8> 9> 本模块接口仅可在Stage模型下使用。 10 11## 导入模块 12 13```js 14import { StartupConfig } from '@kit.AbilityKit'; 15``` 16 17## 属性 18 19**系统能力**:SystemCapability.Ability.AppStartup 20 21 | 名称 | 类型 | 只读 | 可选 | 说明 | 22| -------- | -------- | -------- | -------- | -------- | 23| timeoutMs | number | 是 | 是 | 执行所有启动任务的超时时间,默认值为10000毫秒。 | 24| startupListener | [StartupListener](./js-apis-app-appstartup-startupListener.md) | 是 | 是 | 表示启动框架的监听器,该监听器将在所有启动任务完成时调用。 | 25 26**示例:** 27 28```ts 29import { StartupConfig, StartupConfigEntry, StartupListener } from '@kit.AbilityKit'; 30import { BusinessError } from '@kit.BasicServicesKit'; 31import { hilog } from '@kit.PerformanceAnalysisKit'; 32 33export default class MyStartupConfigEntry extends StartupConfigEntry { 34 onConfig() { 35 hilog.info(0x0000, 'testTag', `onConfig`); 36 let onCompletedCallback = (error: BusinessError<void>) => { 37 hilog.info(0x0000, 'testTag', `onCompletedCallback`); 38 if (error) { 39 hilog.info(0x0000, 'testTag', 'onCompletedCallback: %{public}d, message: %{public}s', error.code, error.message); 40 } else { 41 hilog.info(0x0000, 'testTag', `onCompletedCallback: success.`); 42 } 43 } 44 let startupListener: StartupListener = { 45 'onCompleted': onCompletedCallback 46 } 47 let config: StartupConfig = { 48 'timeoutMs': 10000, 49 'startupListener': startupListener 50 } 51 return config; 52 } 53} 54``` 55