将内容加载到 Blazor TabControl 中

Nic*_*der 5 asp.net-core blazor

我按照此指南和类似指南创建了一个 TabControl:

https://blazor-university.com/templated-components-with-renderfragements/creating-a-tabcontrol/

我的测试 Tabs.razor 页面上的相关代码是:

<TabControl>
  <TabPage Text="Tab 1">
    <h1>The first tab</h1>
  </TabPage>
  <TabPage Text="Tab 2">
    <h1>The second tab</h1>
  </TabPage>
  <TabPage Text="Tab 3">
    <h1>The third tab</h1>
  </TabPage>
</TabControl>
Run Code Online (Sandbox Code Playgroud)

选项卡本身内的页面将包含比只有一句话更多的内容。我发现的所有选项卡式示例都只有这样的选项卡内容,平放在页面上。有没有某种方法可以使选项卡内容更加模块化,可能将其存在于单独的文件中?我希望它全部加载在页面初始化上,我只是不想有一个包含所有选项卡内容的大怪物 .razor 页面。

我不确定这里是否需要嵌套布局或什么,或者渲染如何工作(我需要选项卡内容的行为类似于具有功能和提交操作等的顶级剃刀页面......)。

显然,这还很新鲜,而且还没有找到答案。提前致谢。

Hen*_*man 5

 <TabPage Text="Tab 1">
    <MyFirstTabbedComponent />
  </TabPage>
Run Code Online (Sandbox Code Playgroud)

然后将 MyFirstTabbedComponent.razor 开发为页面/组件。
enfin,你已经做过类似的事情了。