在一些情况下,我们需要在同一个页面中渲染多个根组件,这时候就需要使用Blazor提供的组件占位符(Component Placeholder)来实现。
以下是示例代码:
Sorry, there's nothing at this address.
@ChildContent
Main Layout
This is the main layout.
@ChildContent
Second Component:
Index.razor
@page "/"
Hello, world!
Index Component
SecondComponent.razor
Second Component
Second Component Content
这样就可以在同一个页面中渲染多个根组件。