我正在尝试根据一个 checkbox
来启用/禁用
一组Blazor中的时间
输入; 对于类型为button
的inputs
,下面的解决方案可以工作,但对于类型为time
的inputs
却不能:
适用于按钮输入的解决方案:
<button type="button" class="@this.SetButton"></button>
[Parameter] public bool state { get; set; }
public string SetButton() {
string result = state ? "" : "disabled";
return result;
}
无法正常工作的时间输入尝试:
<input bind="@IsDisabled" type="checkbox" />
<input class="@this.GetGroupState()" type="time" />
protected bool IsDisabled { get; set; }
public string GetGroupState() {
return this.IsDisabled ? "disabled" : "";
}
P.S.:在第一种情况下,bool
作为参数来自另一个component
,因此我不进行绑定。然而,在第二种情况下,它与checkbox
绑定。
disabled="false"
消失。需要一点时间来适应。 - H Hdisabled="@IsDisabled"
和disabled=@IsDisabled
都是完全有效的。 - Chris Sainty