• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 停止PageAbility
2
3
4停止PageAbility通过featureAbility中的terminateSelf接口实现。
5
6
7  **表1** featureAbility接口说明
8
9| 接口名 | 接口描述 |
10| -------- | -------- |
11| terminateSelf() | 停止Ability。 |
12| terminateSelfWithResult(parameter: AbilityResult) | 设置该PageAbility停止时返回给调用者的结果及数据并停止Ability。 |
13
14
15如下示例展示了停止Ability的方法。
16
17```ts
18import featureAbility from '@ohos.ability.featureAbility'
19
20(async () => {
21  try {
22    console.info('Begin to terminateSelf')
23    await featureAbility.terminateSelf()
24    console.info('terminateSelf succeed')
25  }
26  catch (error) {
27    console.error('terminateSelf failed with ' + error)
28  }
29})()
30```
31