gsh*_*arp 17 .net asp.net-core blazor blazor-server-side
有什么区别
@(await Html.RenderComponentAsync<Todo>(RenderMode.ServerPrerendered))
Run Code Online (Sandbox Code Playgroud)
和
@(await Html.RenderComponentAsync<Todo>(RenderMode.Server))
Run Code Online (Sandbox Code Playgroud)
我正在查看文档,但无法真正找到解释差异的内容。并且也不太明白枚举上的代码注释:
// Summary:
// Renders a marker for a Blazor server-side application. This doesn't include any
// output from the component. When the user-agent starts, it uses this marker to
// bootstrap a blazor application.
Server = 2,
//
// Summary:
// Renders the component into static HTML and includes a marker for a Blazor server-side
// application. When the user-agent starts, it uses this marker to bootstrap a blazor
// application.
ServerPrerendered = 3
Run Code Online (Sandbox Code Playgroud)
幕后发生了什么?使用 Server 与 ServerPrerendered 的场景是什么?
dan*_*era 20
在 .NET Core 3.0 Preview 9中的ASP.NET Core 和 Blazor 更新中解释:
- 静态使用指定的参数静态渲染组件。
- 服务器 呈现一个标记,其中组件应由 Blazor 服务器应用程序以交互方式呈现。
- ServerPrerendered 静态预渲染组件和标记,以指示组件稍后应由 Blazor 服务器应用程序交互渲染。
这个概念与性能有关。为页面提供服务的最快方法是静态呈现页面然后发送,而为页面提供服务的最慢方法是提供“交互式 Blazor”服务器页面(通过 SignalR websockets 同步实时虚拟 DOM)。
ServerPrerendered是一种权衡:Blazor 预呈现页面并将其作为静态页面发送,然后该页面成为交互式 Blazor 服务器应用程序。此行为旨在通过基于时间的定位将页面快速提供给搜索引擎。
| 归档时间: |
|
| 查看次数: |
8523 次 |
| 最近记录: |