diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-ability.md b/zh-cn/application-dev/reference/apis/js-apis-application-ability.md index 7da6408723c082cb55b1ac93762a3b548df0e311..b5b953940a80ef71a4f3c4d5d16e5fad63a26c42 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-ability.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-ability.md @@ -8,14 +8,17 @@ Ability模块提供对Ability生命周期、上下文环境等调用管理的能 - [Callee](#callee):通用组件服务端注册和解除客户端caller通知送信的callback接口。 > **说明:** -> -> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +> 从API Version 9开始,该接口不再维护,推荐使用新接口[`@ohos.app.ability.UIAbility (UIAbility)`](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-app-ability-uiAbility.md)。 +> +> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> > 本模块接口仅可在Stage模型下使用。 ## 导入模块 ```ts -import UIAbility from '@ohos.app.ability.UIAbility'; +import UIAbility from '@ohos.application.Ability'; ``` ## 属性 @@ -72,7 +75,7 @@ onWindowStageCreate(windowStage: window.WindowStage): void **示例:** ```ts - class myAbility extends Ability { + export default class EntryAbility extends UIAbility { onWindowStageCreate(windowStage) { console.log('onWindowStageCreate'); } @@ -91,7 +94,7 @@ onWindowStageDestroy(): void **示例:** ```ts - class myAbility extends Ability { + export default class EntryAbility extends UIAbility { onWindowStageDestroy() { console.log('onWindowStageDestroy'); } @@ -116,7 +119,7 @@ onWindowStageRestore(windowStage: window.WindowStage): void **示例:** ```ts - class myAbility extends Ability { + export default class EntryAbility extends UIAbility { onWindowStageRestore(windowStage) { console.log('onWindowStageRestore'); } @@ -135,7 +138,7 @@ Ability生命周期回调,在销毁时回调,执行资源清理等操作。 **示例:** ```ts - class myAbility extends Ability { + export default class EntryAbility extends UIAbility { onDestroy() { console.log('onDestroy'); } @@ -154,7 +157,7 @@ Ability生命周期回调,当应用从后台转到前台时触发。 **示例:** ```ts - class myAbility extends Ability { + export default class EntryAbility extends UIAbility { onForeground() { console.log('onForeground'); } @@ -173,7 +176,7 @@ Ability生命周期回调,当应用从前台转到后台时触发。 **示例:** ```ts - class myAbility extends Ability { + export default class EntryAbility extends UIAbility { onBackground() { console.log('onBackground'); } @@ -205,7 +208,7 @@ onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult; ```ts import AbilityConstant from "@ohos.application.AbilityConstant" - class myAbility extends Ability { + export default class EntryAbility extends UIAbility { onContinue(wantParams) { console.log('onContinue'); wantParams["myData"] = "my1234567"; @@ -233,7 +236,7 @@ onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void; **示例:** ```ts - class myAbility extends Ability { + export default class EntryAbility extends UIAbility { onNewWant(want, launchParams) { console.log('onNewWant, want:' + want.abilityName); console.log('onNewWant, launchParams:' + JSON.stringify(launchParams)); @@ -258,7 +261,7 @@ onConfigurationUpdated(config: Configuration): void; **示例:** ```ts - class myAbility extends Ability { + export default class EntryAbility extends UIAbility { onConfigurationUpdated(config) { console.log('onConfigurationUpdated, language:' + config.language); } @@ -282,7 +285,7 @@ dump(params: Array\): Array\; **示例:** ```ts - class myAbility extends Ability { + export default class EntryAbility extends UIAbility { dump(params) { console.log('dump, params:' + JSON.stringify(params)); return ["params"] @@ -307,7 +310,7 @@ onMemoryLevel(level: AbilityConstant.MemoryLevel): void; **示例:** ```ts - class myAbility extends Ability { + export default class EntryAbility extends UIAbility { onMemoryLevel(level) { console.log('onMemoryLevel, level:' + JSON.stringify(level)); } @@ -338,9 +341,9 @@ onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any}) **示例:** ```ts -import AbilityConstant from '@ohos.application.AbilityConstant' +import AbilityConstant from '@ohos.application.AbilityConstant'; -class myAbility extends Ability { +export default class EntryAbility extends UIAbility { onSaveState(reason, wantParam) { console.log('onSaveState'); wantParam["myData"] = "my1234567"; diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md b/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md index 1c74807e53310bc5529cef01f2cc5c9fcd10e9a4..9290088c53a09d04c8056fdb817d6ec80a373c99 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributedKVStore.md @@ -271,9 +271,10 @@ createKVManager(config: KVManagerConfig): KVManager Stage模型下的示例: ```js -import AbilityStage from '@ohos.application.Ability' +import UIAbility from '@ohos.app.ability.UIAbility'; + let kvManager; -export default class MyAbilityStage extends AbilityStage { +export default class EntryAbility extends UIAbility { onCreate() { console.log("MyAbilityStage onCreate") let context = this.context @@ -294,7 +295,7 @@ export default class MyAbilityStage extends AbilityStage { FA模型下的示例: ```js -import featureAbility from '@ohos.ability.featureAbility' +import featureAbility from '@ohos.ability.featureAbility'; let kvManager; let context = featureAbility.getContext() const kvManagerConfig = {