如何将 Carousel 滑块与 Blazor 中非主页的其他页面隔离

How do I isolate Carousel slider from other pages that is not the home page in Blazor

我想要一个包含页眉、正文和页脚的 HTML 结构,我希望导航栏和旋转木马位于页眉部分。

我该如何做到这一点,以便当用户导航到另一个页面时,虽然导航栏将出现在另一个页面中,但我不希望轮播出现。我该怎么做?

  <header>
    <Navbar/> 
    <carousel/>
  </header>
  <div class="content">
    @Body
  </div>
  <footer>
    This is the footer
  </footer>

注入导航管理器并测试主页 uri 条件。

<header>
    <Navbar/> 
@if (isHomePage)
{
    <carousel/>
}
</header>
<div class="content">
    @Body
</div>
<footer>
    This is the footer
</footer>

@code {
    [Inject]
    NavigationManager Navigation { get; set; }

    bool isHomePage => Navigation.Uri == Navigation.BaseUri;
}