amis2/docs/zh-CN/components/form/button.md

85 lines
1.7 KiB
Markdown
Raw Normal View History

2020-07-28 10:03:53 +08:00
---
title: Button 按钮
2020-07-29 16:20:21 +08:00
description:
2020-07-28 10:03:53 +08:00
type: 0
group: null
menuName: Button
2020-07-29 16:20:21 +08:00
icon:
2020-07-28 10:03:53 +08:00
order: 4
---
2021-01-19 15:48:18 +08:00
按钮用于实现点击时触发行为,比如弹窗等,更多请参考 [Action](../action),在 `form` 中还支持提交和重置功能的按钮。
2020-07-28 10:03:53 +08:00
## 基本用法
```schema: scope="body"
2020-07-28 10:03:53 +08:00
{
"type": "form",
2021-01-19 10:20:09 +08:00
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
2020-07-28 10:03:53 +08:00
"controls": [
{
"type": "text",
"name": "name",
"label": "姓名:"
},
{
"type": "action",
"actionType": "dialog",
"label": "按钮",
"dialog": {
"title": "弹框标题",
"body": "这是一个弹框"
}
}
]
}
```
## 提交表单
请配置`"actionType": "submit"`或`"type": "submit"`按钮,可以触发表单提交行为,
```schema: scope="body"
2020-07-28 10:03:53 +08:00
{
"type": "form",
2021-01-19 10:20:09 +08:00
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
2020-07-28 10:03:53 +08:00
"controls": [
{
"type": "text",
"name": "name",
"label": "姓名:"
},
{
"type": "submit",
"label": "提交"
}
]
}
```
## 重置表单
请配置`"actionType": "reset"`或`"type": "reset"`按钮,可以触发表单提交行为。
```schema: scope="body"
2020-07-28 10:03:53 +08:00
{
"type": "form",
2021-01-19 10:20:09 +08:00
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
2020-07-28 10:03:53 +08:00
"controls": [
{
"type": "text",
"name": "name",
"label": "姓名:"
},
{
"type": "reset",
"label": "重置"
}
]
}
```
## 属性表
2020-07-29 16:20:21 +08:00
见 [Action 行为按钮](../action)