1# FormLink 2 3The **\<FormLink>** component is provided for interactions between static widgets and widget providers. It supports three types of events: router, message, and call. 4 5> **NOTE** 6> 7> - This component is supported since API version 10. Updates will be marked with a superscript to indicate their earliest API version. 8> 9> - This component can be used only in static widgets. 10> 11 12## Required Permissions 13 14None 15 16## Child Components 17 18This component supports only one child component. 19 20## APIs 21 22FormLink(value: { 23 action: string; 24 moduleName?: string; 25 bundleName?: string; 26 abilityName?: string; 27 uri?: string; 28 params?: Object; 29}) 30 31**Parameters** 32 33| Name | Type| Mandatory| Description | 34| ----------- | -------- | ---- | ------------------------------------------------------------ | 35| action | string | Yes | Action type.<br>- **"router"**: redirection to the specified UIAbility of the widget provider.<br>- **"message"**: custom message. If this type of action is triggered, the [onFormEvent()](../apis/js-apis-app-form-formExtensionAbility.md#onformevent) lifecycle callback of the provider FormExtensionAbility is called.<br>- **"call"**: launch of the widget provider in the background. If this type of action is triggered, the specified UIAbility (whose launch type must be [singleton](../../application-models/uiability-launch-type.md#singleton)) of the widget provider is started in the background, but not displayed in the foreground. This action type requires that the widget provider should have the [ohos.permission.KEEP_BACKGROUND_RUNNING](../../security/AccessToken/permissions-for-all.md#ohospermissionkeep_background_running) permission.<br>**NOTE**<br>Whenever possible, avoid using the router event to refresh the widget UI.| 36| moduleName | string | No | Name of the target module when **action** is **"router"** or **"call"**. | 37| bundleName | string | No | Name of the target bundle when **action** is **"router"** or **"call"**. | 38| abilityName | string | No | Name of the target UIAbility when **action** is **"router"** or **"call"**.| 39| uri<sup>11+</sup> | string | No | URI of the target UIAbility when **action** is **"router"** or **"call"**.| 40| params | Object | No | Additional parameters carried in the current action. The value is a key-value pair in JSON format. For the **"call"** action type, the **method** parameter (optional) can be set and its value type must be string.<br>**NOTE**<br>Whenever possible, avoid using **params** to transfer internal state variables of widgets.| 41 42## Attributes 43 44The [universal attributes](ts-universal-attributes-size.md) are supported. 45 46## Events 47 48The [universal events](ts-universal-events-click.md) are not supported. 49 50## Example 51 52```ts 53@Entry 54@Component 55struct FormLinkDemo { 56 build() { 57 Column() { 58 Text("This is a static widget").fontSize(20).margin(10) 59 60 // The router event is used to redirect to the specified UIAbility from the static widget. 61 FormLink({ 62 action: "router", 63 abilityName: "EntryAbility", 64 params: { 65 'message': 'testForRouter' // Customize the message to send. 66 } 67 }) { 68 Button("router event").width(120) 69 }.margin(10) 70 71 72 // The message event triggers the onFormEvent callback of FormExtensionAbility. 73 FormLink({ 74 action: "message", 75 abilityName: "EntryAbility", 76 params: { 77 'message': 'messageEvent' // Customize the message to send. 78 } 79 }) { 80 Button("message event").width(120) 81 }.margin(10) 82 83 84 // The call event is used to call the specified method in the UIAbility. 85 FormLink({ 86 action: "call", 87 abilityName: "EntryAbility", 88 params: { 89 'method': 'funA', // Set the name of the method to call in the EntryAbility. 90 'num': 1 // Set other parameters to be passed in. 91 } 92 }) { 93 Button("call event").width(120) 94 }.margin(10) 95 96 // The router deeplink event is used to redirect to the specified UIAbility from the static widget. 97 FormLink({ 98 action: "router", 99 uri: 'example://uri.ohos.com/link_page', 100 params: { 101 message: 'router msg for static uri deeplink' // Customize the message to send. 102 } 103 }) { 104 Button("deeplink event").width(120) 105 }.margin(10) 106 } 107 .justifyContent(FlexAlign.Center) 108 .width('100%').height('100%') 109 } 110} 111``` 112 113 114