Ale*_*dre 6 blazor blazor-server-side asp.net-core-3.0
要在 ASP.NET Core Preview 3 上禁用服务器端预渲染,您只需注释@(await Html.RenderComponentAsync<MyApp>()).
从 asp.net core 预览版 4 开始,当您注释此行时,页面不会呈现,并且在主组件上@page "/",标记<app>保持空白。
那么,我们如何禁用服务器端预渲染呢?
要禁用预渲染,请打开Pages/_Host.cshtml文件并将render-modeComponent Tag Helper 的属性更改为 Server: CSHTML
<component type="typeof(App)" render-mode="Server" />
Run Code Online (Sandbox Code Playgroud)
Pages/_Layout.cshtml 中禁用内容预渲染:CSHTML
<component type="typeof(HeadOutlet)" render-mode="Server" />
Run Code Online (Sandbox Code Playgroud)
最后在github中通过cores-system找到了解决方案来源:https://github.com/aspnet/AspNetCore/issues/9584#issuecomment-485257261
app.UseEndpoints(endpoints =>
{
endpoints.MapBlazorHub().AddComponent<App>(selector: "app");
endpoints.MapFallbackToFile("index.html"); // or - endpoints.MapFallbackToPage("/_Host");
});
Run Code Online (Sandbox Code Playgroud)
希望这有效...
| 归档时间: |
|
| 查看次数: |
10029 次 |
| 最近记录: |