提交 173c11a4 编写于 作者: J jiangdayuan

add formlink

Signed-off-by: Njiangdayuan <jiangdayuan@huawei.com>
Change-Id: I7c6ccae9086d431f6cfaf245375b2dcad4163b27
上级 4fdb615a
......@@ -116,6 +116,7 @@
- [Counter](ts-container-counter.md)
- [Flex](ts-container-flex.md)
- [FlowItem](ts-container-flowitem.md)
- [FormLink](ts-container-formlink.md)
- [GridCol](ts-container-gridcol.md)
- [GridRow](ts-container-gridrow.md)
- [Grid](ts-container-grid.md)
......
......@@ -288,9 +288,12 @@
- [RemoteWindow](ts-basic-components-remotewindow.md)
远程控制窗口组件,可以通过此组件控制应用窗口,提供启动退出过程中控件动画和应用窗口联动动画的能力。
- [Formcomponent](ts-basic-components-formcomponent.md)
- [FormComponent](ts-basic-components-formcomponent.md)
提供卡片组件,实现卡片的显示功能。
- [FormLink](ts-container-formlink.md)
提供静态卡片事件交互功能。
- [Menu](ts-basic-components-menu.md)
以垂直列表形式显示的菜单。
......
# FormLink
提供静态卡片交互组件,用于静态卡片内部和提供方应用间的交互,当前支持router、message和call三种类型的事件。
> **说明:**
>
> - 该组件从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
>
> - 该组件仅可以在静态卡片中使用。
>
## 权限
## 子组件
支持单个子组件
## 接口
FormLink(value: {
action: string;
moduleName?: string;
bundleName?: string;
abilityName: string;
params: Object;
})
**参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 |
| ----------- | -------- | ---- | ------------------------------------------------------------ |
| action | string | 是 | action的类型,支持三种预定义的类型:<br/>-&nbsp;"router":跳转到提供方应用的指定UIAbility。<br/>-&nbsp;"message":自定义消息,触发后会调用提供方FormExtensionAbility的[onFormEvent()](../apis/js-apis-app-form-formExtensionAbility.md#onformevent)生命周期回调。<br/>-&nbsp;"call":后台启动提供方应用。触发后会拉起提供方应用的指定UIAbility(仅支持[launchType](../../application-models/uiability-launch-type.md)为singleton的UIAbility,即启动模式为单实例的UIAbility),但不会调度到前台。提供方应用需要具备后台运行权限([ohos.permission.KEEP_BACKGROUND_RUNNING](../../security/permission-list.md#ohospermissionkeep_background_running))。 |
| moduleName | string | 否 | "router"&nbsp;/&nbsp;"call"&nbsp;类型时跳转的模块名,可选。 |
| bundleName | string | 否 | "router"&nbsp;/&nbsp;"call"&nbsp;类型时跳转的包名,可选。 |
| abilityName | string | 是 | "router"&nbsp;/&nbsp;"call"&nbsp;类型时跳转的UIAbility名,必填。 |
| params | Object | 是 | 当前action携带的额外参数,内容使用JSON格式的键值对形式。"call"&nbsp;类型时需填入参数'method',且类型需要为string类型,用于触发UIAbility中对应的方法,必填。 |
## 属性
支持[通用属性](ts-universal-attributes-size.md)
## 事件
不支持[通用事件](ts-universal-events-click.md)
## 示例
```ts
@Entry
@Component
struct FormLinkDemo {
build() {
Column() {
Text("这是一个静态卡片").fontSize(20).margin(10)
// router事件用于静态卡片跳转到对应的UIAbility
FormLink({
action: "router",
abilityName: "EntryAbility",
params: {
'message': 'testForRouter' // 自定义要发送的message
}
}) {
Button("router event").width(120)
}.margin(10)
// message事件触发FormExtensionAbility的onFormEvent生命周期
FormLink({
action: "message",
abilityName: "EntryAbility",
params: {
'message': 'messageEvent' // 自定义要发送的message
}
}) {
Button("message event").width(120)
}.margin(10)
// call事件用于触发UIAbility中对应的方法
FormLink({
action: "call",
abilityName: "EntryAbility",
params: {
'method': 'funA', // 在EntryAbility中调用的方法名
'num': 1 // 需要传递的其他参数
}
}) {
Button("call event").width(120)
}.margin(10)
}
.justifyContent(FlexAlign.Center)
.width('100%').height('100%')
}
}
```
![FormLink](figures/formLink.jpeg)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册