当输入(HTML)的值改变时,有没有办法调用方法?但不是当输入的焦点丢失时而是当我在 HTML 输入中输入字符时。
我使用@bind 将字段绑定到输入。
然后我尝试使用 @onkeydown 和 @onkeyup 来调用该方法。但是最后插入的字符还没有添加到有界字段中。
我也尝试使用@onchange,但随后我会收到错误消息“该元素的属性 onchange 被使用了两次或更多次。 - 我认为该债券也订阅了此事件。
我的最后一个想法是为债券使用(完整)属性而不是字段。在属性的 setter 中,我调用了该函数。但问题是,当 HTML 输入失去焦点时调用 setter。
<table class="table table-condensed table-hover" data-click-to-select="true">
<thead class="custom-headline">
<tr>
<th class="align-text-top">
@indexText.index_table_title<br />
<input type="text" @onkeydown="Test" @bind="titleSearch" />
</th>
...
Run Code Online (Sandbox Code Playgroud)
有人知道如何解决这个问题吗?
先谢谢了!
最好的问候马蒂亚斯
你可以这样做:
<input type="text" @bind-value:event="oninput" @bind-value="titleSearch" />
@code {
private string titleSearch{ get; set; }
}
Run Code Online (Sandbox Code Playgroud)
现在,在每次敲击键盘时都会调用 input 事件,并且更新 titleSearch 属性的值以反映这一点...
希望这有助于...
| 归档时间: |
|
| 查看次数: |
313 次 |
| 最近记录: |