admin管理员组

文章数量:1131431

I have the following project (Blazor WASM), where, in my NavMenu.razor, the options of the "Products" submenu are not displayed. The menu is based on Bootstrap 5. I am new to this. Please, could someone help me? Thank you very much in advance.

I can't find in the Bootstrap documentation how to solve this problem. Thanks

My code in the NavMenu is:

<nav class="navbar navbar-expand-lg bg-dark">
    <div class="container">
        <a class="navbar-brand text-white" href="/">Sistema Comanda</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                <NavLink class="nav-link text-white" href="/" Match="NavLinkMatch.All">
                    <span class="p-2"></span> Inicio
                </NavLink>


                <div class="dropdown">
                    <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                        Maestros
                    </button>
                    <ul class="dropdown-menu dropdown-menu-dark">
                        <li>
                            <div class="dropdown">
                                <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                                    Productos
                                </button>
                                <ul class="dropdown-menu dropdown-menu-dark">
                                    <li><a class="dropdown-item" href="familiarecetas">Familias</a></li>
                                    <li><a class="dropdown-item" href="">Ítems</a></li>
                                </ul>
                            </div>
                        </li>
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item" href="locales">Locales</a></li>
                    </ul>
                </div>


                <NavLink class="nav-link text-white" href="locales">
                    <span class="p-2"></span> Locales
                </NavLink>
                <NavLink class="nav-link text-white" href="familiarecetas">
                    <span class="p-2"></span> Familias de Recetas
                </NavLink>
            </ul>



            <ul class="navbar-nav mr-auto mb-2 mb-lg-0">
                <NavLink class="nav-link text-white" href="registrarse">
                    <span class="p-2"></span> Registrarse
                </NavLink>
                <NavLink class="nav-link text-white" href="acceder">
                    <span class="p-2"></span> Acceder
                </NavLink>
            </ul>
        </div>
    </div>
</nav>

@code {
    private bool collapseNavMenu = true;

    private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;

    private void ToggleNavMenu()
    {
        collapseNavMenu = !collapseNavMenu;
    }
}

I tried to solve it by looking at the documentation of Bootstrap itself and others but I was unsuccessful.

I have the following project (Blazor WASM), where, in my NavMenu.razor, the options of the "Products" submenu are not displayed. The menu is based on Bootstrap 5. I am new to this. Please, could someone help me? Thank you very much in advance.

I can't find in the Bootstrap documentation how to solve this problem. Thanks

My code in the NavMenu is:

<nav class="navbar navbar-expand-lg bg-dark">
    <div class="container">
        <a class="navbar-brand text-white" href="/">Sistema Comanda</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                <NavLink class="nav-link text-white" href="/" Match="NavLinkMatch.All">
                    <span class="p-2"></span> Inicio
                </NavLink>


                <div class="dropdown">
                    <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                        Maestros
                    </button>
                    <ul class="dropdown-menu dropdown-menu-dark">
                        <li>
                            <div class="dropdown">
                                <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                                    Productos
                                </button>
                                <ul class="dropdown-menu dropdown-menu-dark">
                                    <li><a class="dropdown-item" href="familiarecetas">Familias</a></li>
                                    <li><a class="dropdown-item" href="">Ítems</a></li>
                                </ul>
                            </div>
                        </li>
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item" href="locales">Locales</a></li>
                    </ul>
                </div>


                <NavLink class="nav-link text-white" href="locales">
                    <span class="p-2"></span> Locales
                </NavLink>
                <NavLink class="nav-link text-white" href="familiarecetas">
                    <span class="p-2"></span> Familias de Recetas
                </NavLink>
            </ul>



            <ul class="navbar-nav mr-auto mb-2 mb-lg-0">
                <NavLink class="nav-link text-white" href="registrarse">
                    <span class="p-2"></span> Registrarse
                </NavLink>
                <NavLink class="nav-link text-white" href="acceder">
                    <span class="p-2"></span> Acceder
                </NavLink>
            </ul>
        </div>
    </div>
</nav>

@code {
    private bool collapseNavMenu = true;

    private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;

    private void ToggleNavMenu()
    {
        collapseNavMenu = !collapseNavMenu;
    }
}

I tried to solve it by looking at the documentation of Bootstrap itself and others but I was unsuccessful.

Share Improve this question edited Jan 8 at 7:59 Qiang Fu 8,1231 gold badge6 silver badges16 bronze badges asked Jan 7 at 23:36 Mario EscuderoMario Escudero 136 bronze badges 2
  • Can you show the Bootstrap scripts (CSS, JS) that you imported in index.html? – Yong Shun Commented Jan 8 at 1:57
  • Your provided code doesn't have any "Products" submenu. – Yong Shun Commented Jan 8 at 2:27
Add a comment  | 

1 Answer 1

Reset to default 0

You could try this NavMenu works for grand toggle:

<nav class="navbar navbar-expand-lg bg-dark">
    <div class="container">
        <a class="navbar-brand text-white" href="/">Sistema Comanda</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon bg-white"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                    <NavLink class="nav-link text-white" href="/" Match="NavLinkMatch.All">
                        <span class="p-2"></span> Inicio
                    </NavLink>
                    <!-- Services with Submenu (Click Toggle) -->
                    <li class="nav-item">
                        <a class="nav-link dropdown-toggle text-white" data-bs-toggle="collapse" href="#servicesMenu" role="button"
                           aria-expanded="false" aria-controls="servicesMenu">
                        <span class="p-2"></span>Maestros
                        </a>
                        <div class="collapse" id="servicesMenu">
                            <ul class="list-unstyled ps-3">

                                <!-- Grand Submenu (Click Toggle) -->
                                <li>
                                    <a class="nav-link dropdown-toggle text-white" data-bs-toggle="collapse" href="#moreServicesMenu"
                                       role="button" aria-expanded="false" aria-controls="moreServicesMenu">
                                        Productos
                                    </a>
                                    <div class="collapse ps-3" id="moreServicesMenu">
                                        <ul class="list-unstyled">
                                            <li><a class="dropdown-item text-white" href="familiarecetas">Familias</a></li>
                                            <li><a class="dropdown-item text-white" href="">Ítems</a></li>
                                        </ul>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </li>
                    <NavLink class="nav-link text-white" href="locales">
                        <span class="p-2"></span> Locales
                    </NavLink>

                    <NavLink class="nav-link text-white" href="familiarecetas">
                        <span class="p-2"></span> Familias de Recetas
                    </NavLink>

            </ul>
            <ul class="navbar-nav mr-auto mb-2 mb-lg-0">
                <NavLink class="nav-link text-white" href="registrarse">
                    <span class="p-2"></span> Registrarse
                </NavLink>
                <NavLink class="nav-link text-white" href="acceder">
                    <span class="p-2"></span> Acceder
                </NavLink>
            </ul>
        </div>
    </div>
</nav>

本文标签: cProblem with display in sub menu with BlazorStack Overflow