我正在 Blazor 中添加一个表单,我正在按照此处指定的说明进行操作
https://docs.microsoft.com/en-us/aspnet/core/blazor/forms-validation?view=aspnetcore-3.0
是否可以添加带有密码掩码的输入。
我尝试添加做类似的事情
public class LoginModel
{
[Required]
public string Username { get; set; }
[Required]
[DataType(DataType.Password)]
public string Password { get; set; }
}
但这没有用。有没有办法在输入时隐藏密码?
最佳答案
您可以使用 InputText
组件与 type=password
:
<EditForm Model="@model">
<DataAnnotationsValidator />
<ValidationSummary />
<InputText type="password" placeholder="Password" @bind-Value="@model.Password" />
</EditForm>
@code {
class Login
{
[Required]
public string Password { get; set; }
}
private Login model = new Login();
}
InputText
支持所有<input />
属性
关于.net - 输入密码 Blazor 表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58542527/