Shr*_*rey 2 c# razor razor-pages blazor blazor-webassembly
我对几乎所有属性都使用 InputText。某些属性的类型为 Double。当我在 InputText 中绑定双精度值时,它给了我错误。我该如何解决这个问题?我不想使用输入编号。
<div class="form-group col">
<label title="The quantity ">Quantity</label>
<i class="fa fa-info-circle" style="color:dimgrey" title="The quantity">
</i>
<InputText @bind-Value="@trade.qty" class="form-control" />
<ValidationMessage For="@(() => trade.qty)" />
</div>
Run Code Online (Sandbox Code Playgroud)
我在 @trade.qty 处收到错误,<InputText @bind-Value="@trade.qty" class="form-control" />
因为它的值是双精度的。
模型:
public Double qty { get; set; }
Run Code Online (Sandbox Code Playgroud)
我尝试过类似的方法,<InputText @bind-Value="@trade.qty.ToString()" class="form-control" />
但没有成功。
小智 5
使用
<InputNumber @bind-Value=trade.qty min="1" max="999" />
Run Code Online (Sandbox Code Playgroud)
它可以绑定为双倍。
https://learn.microsoft.com/fr-fr/aspnet/core/blazor/forms-validation?view=aspnetcore-5.0
| 归档时间: |
|
| 查看次数: |
3131 次 |
| 最近记录: |