Blazor 将字段设为只读

问题描述 投票:0回答:2
c# html blazor readonly
2个回答
5
投票

你可以这样做,你可以根据你的要求设置

IsDisabled

@code{
    protected bool IsDisabled { get; set; }
}

<InputText class="@("cursor-disabled "+ input100)" disabled="@IsDisabled" name="addressLine1" placeholder="County Code..." @bind-Value="_model.CountyCode" />

0
投票

只需使用经典的 HTML 标签

<input>
并添加
readonly
(但不是 readonly="true")

<input type="text" class="@("cursor-disabled "+ input100)"  id="addressLine1" name="addressLine1" placeholder="County Code..." @bind-Value="_model.CountyCode" readonly />

© www.soinside.com 2019 - 2024. All rights reserved.