• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Custom Component Built-in APIs
2
3Custom component built-in APIs are APIs predefined on the base class of custom components in the ArkUI framework. You can call these APIs on the instance of a custom component to obtain information, such as the UI context, about the instance.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8>
9
10## getUIContext
11
12getUIContext(): UIContext
13
14Obtains the **UIContext** instance.
15
16**System capability**: SystemCapability.ArkUI.ArkUI.Full
17
18**Return value**
19
20| Type                                                     | Description                   |
21| --------------------------------------------------------- | ----------------------- |
22| [UIContext](../apis/js-apis-arkui-UIContext.md#uicontext) | **UIContext** instance obtained.|
23
24**Example**
25
26```ts
27import { UIContext } from '@ohos.arkui.UIContext';
28
29@Entry
30@Component
31struct MyComponent {
32  aboutToAppear() {
33    let uiContext: UIContext = this.getUIContext();
34  }
35
36  build() {
37    // ...
38  }
39}
40```
41
42## queryNavDestinationInfo
43
44queryNavDestinationInfo(): NavDestinationInfo | undefined;
45
46Obtains the **NavDestinationInfo** instance.
47
48**System capability**: SystemCapability.ArkUI.ArkUI.Full
49
50**Return value**
51
52| Type                                                                      | Description     |
53| -------------------------------------------------------------------------- | --------- |
54| [NavDestinationInfo](../apis/js-apis-arkui-observer.md#navdestinationinfo) \| undefined | **NavDestinationInfo** instance obtained.|
55
56**Example**
57
58```ts
59import observer from '@ohos.arkui.observer';
60
61@Entry
62@Component
63struct MyComponent {
64  aboutToAppear() {
65    let info: observer.NavDestinationInfo | undefined = this.queryNavDestinationInfo();
66  }
67
68  build() {
69    // ...
70  }
71}
72```
73