From 71dd4aaff883e4b22d4b69f85279270715c4bbc2 Mon Sep 17 00:00:00 2001 From: zyjhandsome Date: Sat, 14 Jan 2023 09:42:02 +0800 Subject: [PATCH] =?UTF-8?q?@ohos.application.Ability=20(Ability)=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=8F=8F=E8=BF=B0=E4=B8=AD=E5=A2=9E=E5=8A=A0=E6=A0=87?= =?UTF-8?q?=E5=BA=9F=E5=BC=83=E8=AF=B4=E6=98=8E=E3=80=82=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E4=BD=8D=E7=BD=AE=E6=9B=BF=E6=8D=A2=E4=B8=BA?= =?UTF-8?q?=E6=96=B0=E6=8E=A5=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zyjhandsome --- .../apis/js-apis-application-ability.md | 35 ++++++++++--------- .../apis/js-apis-distributedKVStore.md | 7 ++-- 2 files changed, 23 insertions(+), 19 deletions(-) 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 7da6408723..b5b953940a 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 1c74807e53..9290088c53 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 = { -- GitLab