想要给表单确定按钮绑定一个自定义点击方法

点击后做什么操作?好奇,截图貌似还是老版本。
是想让确定按钮去执行一个自己的后端接口调用方法
actionType 配置成 'ajax', 然后配置 api 属性就够了。这里面有很多种按钮类型。
https://baidu.github.io/amis/docs/renderers/Action
是这样的,我是有一套后端接口调用函数,是想用这个确认按钮去调用。
确认按钮就是配置个 actionType 为 'ajax' 类型的按钮,然后配置 api, 再配置个 confirmText 就完了。
点击的时候自动会弹出个确认框,确认完了就会走 ajax 操作。
跟这个栗子的用法时一样的。https://baidu.github.io/amis/crud/table?page=1
ps:左上角可以查看源码。
那是没办法,给确认按钮配置可以去调用函数吗?
作者大大这个我是知道的,只不过需求是要用确认按钮去调用函数。
调用后端的函数都是走 api,你的意思是前端的函数?
是的前端函数
如果你是用 js 来配置 amis,可以这么弄。
{
type: "button"
label: "删除",
actionType: "dialog",
dialog: {
title: "系统消息",
body: "确认要删除?",
actions: [
{
type: "button",
label: "确认",
actionType: "close"
onClick: () => {
alert('clicked');
// return false 可以阻止 amis 里面后续的动作。
}
},
{
label: "取消",
type: "button",
actionType: "close"
}
]
}
}
作者大大,我在onClik写了一个函数,它并不加载该函数,甚至actionType以下都不执行。


最外层的 onClick 进去没?
在props.onAction前面的都执行了
---原始邮件--- 发件人: "liaoxuezhi"<[email protected]> 发送时间: 2019年12月17日(周二) 下午5:28 收件人: "baidu/amis"<[email protected]>; 抄送: "Author"<[email protected]>;"x1194785386"<[email protected]>; 主题: Re: [baidu/amis] 想要给表单确定按钮绑定一个自定义点击方法 (#380)
最外层的 onClick 进去没?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
看这像是进入了第二个分支。你看看 第二个 onAction 那块
好的我先理理
---原始邮件--- 发件人: "liaoxuezhi"<[email protected]> 发送时间: 2019年12月17日(周二) 下午5:47 收件人: "baidu/amis"<[email protected]>; 抄送: "Author"<[email protected]>;"x1194785386"<[email protected]>; 主题: Re: [baidu/amis] 想要给表单确定按钮绑定一个自定义点击方法 (#380)
那就没问题了,你下面一看就好乱,自己先理一理。
不知道你 viewJson 是啥
用了 map,但是 方法没有返回。
actionName 是啥?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
作者大大我这边代码少了一层return false;,已经解决了,麻烦您了。