【发布时间】:2021-03-08 08:34:48
【问题描述】:
如何使用 ICommand 在 Button click 中执行表单提交
如何在ICommand执行中传递参数
@using System.Windows.Input
<button @onclick="buttonClick"> Blazor Button</button>
@code {
private ICommand _command;
public ICommand Command
{
get => _command;
set => _command = value;
}
private void buttonClick()
{
this.Command?.Execute(null);
}
}
【问题讨论】:
-
您是否有特殊原因要从 ICommand 触发表单提交?做一个普通的
<button type="submit">,然后设置你要提交的表单的OnValidSubmit,会不会容易很多? -
我的要求如何在 ICommand.exceute 中传递参数。