我尝试使用处理 Blazor 中的onclose
事件dialog
。我尝试使用该@onclose
属性,但它不起作用。
<dialog @onclose="MyEventHandler">
</dialog>
@code {
async Task MyEventHandler()
{
}
}
这会产生以下错误:
Unhandled exception rendering component: InvalidCharacterError: Failed to execute 'setAttribute' on 'Element': '@onclose' is not a valid attribute name.
System.InvalidOperationException: InvalidCharacterError: Failed to execute 'setAttribute' on 'Element': '@onclose' is not a valid attribute name.
at Microsoft.AspNetCore.Components.RenderTree.Renderer.InvokeRenderCompletedCallsAfterUpdateDisplayTask(Task updateDisplayTask, Int32[] updatedComponents)
是否可以在 Blazor 中处理此事件?
环境:
- Blazor - 服务器端渲染
- .NET 核心 3.1