【发布时间】:2021-06-02 09:00:53
【问题描述】:
我已经习惯了 Blazor WASM。 我有一些从自定义基类继承的页面。 在这个基类中,我有一个级联参数。
public class CustomBlazorComponentBase : LayoutComponentBase
{
private bool disposedValue;
[Inject]
protected HttpInterceptorService Interceptor { get; set; }
[CascadingParameter]
protected TelerikNotification Notification { get; set; }
protected override Task OnInitializedAsync()
{
Interceptor.RegisterEvent(Notification.ShowError);
return base.OnInitializedAsync();
}
}
在 MainLayout.razor 中我得到了以下几行
<CascadingValue IsFixed="true" Value="@Notification">
<div class="content px-4">
@Body
</div>
</CascadingValue>
<TelerikNotification @ref="@Notification" Class="notification"
HorizontalPosition="@NotificationHorizontalPosition.Center"
VerticalPosition="@NotificationVerticalPosition.Bottom" />
页面开始
@inherits ItnBlazorComponentBase
如果出现问题,HttpInterceptor-Class 会获得一个委托来显示错误。 一切正常,符合预期。
但是当用户不小心按下浏览器的 F5 来刷新页面时,没有调用 Lifecycle-Method。不是 OnInitializedAsync,不是 OnParametersSetAsync 等等。
为什么?以及如何避免这个问题? 问题是,我的代表不会注册,因此不会显示任何通知。
谢谢!
【问题讨论】:
标签: c# telerik blazor-webassembly