RenderComponentAsync 与 html?预渲染 blazor?
RenderComponentAsync vs html? prerender blazor?
<div id="Counter">
@(await Html.RenderComponentAsync<Counter>(new { IncrementAmount = 10 }))
</div>
当我可以使用时为什么要使用它
<counter IncrementAmount="10"/>
"When the page or view is rendered, components are prerendered at the same time."
https://docs.microsoft.com/en-us/aspnet/core/blazor/components?view=aspnetcore-3.0
谢谢
当您想要将 Blazor 组件包含到 MVC 视图或 Razor 页面中时,将使用您引用的代码示例。如果你只是在编写一个标准的 Blazor 应用程序,那么你就不需要这种语法。
使用此语法时,组件将在服务器上预呈现,并在与客户端浏览器建立 SignalR 连接后变为交互式。
<div id="Counter">
@(await Html.RenderComponentAsync<Counter>(new { IncrementAmount = 10 }))
</div>
当我可以使用时为什么要使用它
<counter IncrementAmount="10"/>
"When the page or view is rendered, components are prerendered at the same time."
https://docs.microsoft.com/en-us/aspnet/core/blazor/components?view=aspnetcore-3.0
谢谢
当您想要将 Blazor 组件包含到 MVC 视图或 Razor 页面中时,将使用您引用的代码示例。如果你只是在编写一个标准的 Blazor 应用程序,那么你就不需要这种语法。
使用此语法时,组件将在服务器上预呈现,并在与客户端浏览器建立 SignalR 连接后变为交互式。