[英]Blazor prerendering show layout
我正在嘗試實現 blazor 預渲染。 它似乎工作正常,但是當我刷新頁面時,布局(實際路由頁面的容器)不可見。 我按照https://jonhilton.net/blazor-wasm-prerendering/此處的說明在服務器項目中創建了一個 _Host.cshtml 文件。 但不包括如下所示的 Client/App.razor:
<Fluxor.Blazor.Web.StoreInitializer />
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<AppRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>@Frontend.ErrotPage_NotFoundTitle</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<MudAlert Severity="Severity.Error" Variant="Variant.Filled" Square="true" Class="ma-2">@Frontend.ErrorPage_NotFound</MudAlert>
</LayoutView>
</NotFound>
</Router>
我是否必須將此文件移動到服務器項目,或者完成此操作的正確方法是什么?
似乎布局已經呈現。 但是它的某些部分沒有被渲染,因為它取決於當前用戶,而當前用戶在服務器端不可用。 解決方案是在服務器端也提供當前用戶(Blazor 6 尚無法實現)。
這是 danroth27 編寫的 .NET 6 版本的 GitHub 存儲庫
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.