harmony 鸿蒙AbilityComponent

  • 2022-08-09
  • 浏览 (771)

AbilityComponent

<AbilityComponent> is a container for independently displaying an ability.

NOTE

This component is deprecated since API version 10. You are advised to use <UIExtensionComponent> instead.

This component is supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version.

The APIs provided by this component are system APIs.

Constraints

<AbilityComponent> is rendered independently and cannot be overlaid with other display content.

<AbilityComponent> cannot process input events. Events are directly distributed to the internal ability for processing without passing through the current ability.

Only width and height can be set for <AbilityComponent>. These attributes are mandatory and cannot be dynamically updated.

The ability to be started must inherit WindowExtension.

Child Components

Not supported

APIs

AbilityComponent(want: Want)

Parameters

Name Type Mandatory Description
want Want Yes Description of the default ability to load.

Events

onConnect

onConnect(callback:() =&gt; void)

Called when this <AbilityComponent> is started. You can then use APIs in the <AbilityComponent>.

onDisconnect

onDisconnect(callback:() =&gt; void)

Called when this <AbilityComponent> is destroyed.

Example

// xxx.ets
@Entry
@Component
struct MyComponent {

  build() {
      Column() {
          AbilityComponent({
              want: {
                  bundleName: '',
                  abilityName: ''
              },
          })
          .onConnect(() => {
              console.log('AbilityComponent connect')
          })
          .onDisconnect(() => {
              console.log('AbilityComponent disconnect')
          })
      }
  }
}

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkTS-based Declarative Development Paradigm

harmony 鸿蒙@ohos.multimedia.avCastPicker (AVCastPicker)

harmony 鸿蒙Property Animation

harmony 鸿蒙Enums

harmony 鸿蒙Blank

harmony 鸿蒙Button

harmony 鸿蒙CalendarPicker

harmony 鸿蒙Checkbox

harmony 鸿蒙CheckboxGroup

harmony 鸿蒙DataPanel

0  赞