asp.net-core - 将内容加载到 Blazor TabControl

标签 asp.net-core blazor

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

https://blazor-university.com/templating-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>

选项卡本身内的页面将包含比一句话更多的内容。我发现的所有选项卡式示例都只有这样的选项卡内容,平铺在页面上。有没有办法让标签内容更加模块化,可能让它存在于单独的文件中?我希望这一切都加载到页面初始化中,我只是希望没有一个包含所有选项卡内容的大型怪物 .razor 页面。

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

显然,这很新,并且无法找到答案。提前致谢。

最佳答案

 <TabPage Text="Tab 1">
    <MyFirstTabbedComponent />
  </TabPage>

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

关于asp.net-core - 将内容加载到 Blazor TabControl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60302880/

相关文章:

c# - Asp.net 核心问题中的分页,只得到 10 个项目不能让它更快?

google-chrome - 更新后在 Chrome 中无法登录 Blazor WASM

c# - 无法发布 .Net Blazor 应用程序 : The application was terminated by a signal: SIGHUP

c# - 浏览器链接不刷新 Chrome 中的页面

c# - 无法将 Serilog 配置代码行转换为 json 配置

c# - 使用 Web API 过滤

asp.net-core - ASP.NET Core 中 Web.config 转换的等价物是什么?

asp.net-core - Windows 身份验证模拟在 ASP.NET Core 中已失效吗?

asp.net-core - 在 MVC View /Razor 页面中使用 RenderComponentAsync (Blazor WebAssembly)

asp.net-core - Blazor - WebAssembly ASP.NET Core 托管模型