【问题标题】:.net Core / Blazor : @onkeypress="@(e => OnKeyPressEvent(e))" does not work as it should when app is deployed to IIS:.net Core / Blazor:@onkeypress="@(e => OnKeyPressEvent(e))" 在将应用程序部署到 IIS 时无法正常工作:
【发布时间】:2020-07-19 23:52:07
【问题描述】:

调试时,“Enter”触发该事件,但当应用程序在 IIS 上发布时,它只工作一次。我注意到当它不起作用时,它会放置一个“?”在它尝试联系的 URL 末尾: “/数据?”

非常感谢这里的任何帮助。 谢谢

<input type="text"  @bind-value="@Tags" @bind-value:event="oninput" @onkeypress="@(e => OnKeyPressEvent(e))" /> ```

@Code{
    void OnKeyPressEvent(KeyboardEventArgs args)
    {

        if (args.Key == "Enter")
        {
            DoSomething-OK();            
        }
    }
}





【问题讨论】:

  • 你能分享你的代码并展示你是如何做到的吗?
  • 请见上文。 :)
  • 您的代码中没有网址。更好地描述它。
  • 另外,绑定事件的正常方式:@onkeypress="OnKeyPressEvent"
  • 代码看起来基本没问题,这很可能是 DoSomething-OK() 中的一些问题。写一个合适的minimal reproducible example

标签: .net iis .net-core blazor


【解决方案1】:

这是我发现的问题的解决方案: 1- 表单需要在提交时设置为 False,这样它就不会重新加载整个组件。

<form class="SearchBarExample" onsubmit="return false">
<input type="text" size="100" placeholder="Search here..."@bind-value="@Tags" @bind-value:event="oninput"@onkeyup="OnKeyUPEvent" />
</form>


【讨论】:

    猜你喜欢
    • 2019-01-17
    • 2019-07-09
    • 1970-01-01
    • 2020-04-02
    • 2023-03-06
    • 2018-02-16
    • 1970-01-01
    • 2020-09-13
    • 2020-02-09
    相关资源
    最近更新 更多