相关疑难解决方法(0)

Blazor:在使用 @bind 时如何在 <select> 中使用 onchange 事件?

我需要能够在<select>. 问题是我也绑定了@bind,当我尝试使用@onchange 时出现错误,指出@bind 已经在使用它。我尝试使用@onselectionchange,但这没有任何作用(不运行该功能)。我可以忘记@bind 而只是将@onchange 分配给一个函数,但我不确定如何将选定的值传递给该函数。

我有以下代码:

<select @bind="@SelectedCustID" @ @onchange="@CustChanged" class="form-control">
    @foreach (KeyGuidPair i in CustList)
    {
        <option value="@i.Value">@i.Text</option>
    }
</select>
Run Code Online (Sandbox Code Playgroud)

谢谢。

select bind onchange blazor

32
推荐指数
6
解决办法
3万
查看次数

标签 统计

bind ×1

blazor ×1

onchange ×1

select ×1