引导下拉菜单中没有第一次点击后工作(Bootstrap DropDown menu doesn

2019-10-22 05:10发布

我有我的下拉菜单中我_Layout.cshtml并点击菜单项中的一个正常工作的第一时间,例如需要我的http://本地主机:52098 /首页/ ViewTable /苏格兰联赛。

如果我再次点击该网址,它试图以我的http://本地主机:52098 /首页/ ViewTable /主页/ ViewTable /苏格兰英超

导航代码:

div class="navbar navbar-inverse navbar-fixed-top">
            <ul class="nav nav-pills">
                <li role="presentation" class="dropdown">
                    <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
                        Scotland <span class="caret"></span></a>
                        <ul class="dropdown-menu multi-level" role="menu">
                            <li role="presentation"><a role="menuitem" tabindex="-1" href="Home/ViewTable/Scottish Premiership">
                                Scottish Premiership
                            </a></li>
                            <li role="presentation">
                                <a role="menuitem" tabindex="-1" href="Home/ViewMain/Scottish Championship">
                                    Scottish Championship
                                </a>
                            </li>
                            <li role="presentation">
                                <a role="menuitem" tabindex="-1">
                                   Scottish First Division
                                </a>
                            </li>
                            <li role="presentation">
                                <a role="menuitem" tabindex="-1">
                                   Scottish Second Division
                                </a>
                            </li>

                        </ul>
               </li>
                <li role="presentation" class="dropdown">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-expanded="false">
                        England <span class="caret"></span>
                        <ul class="dropdown-menu" role="menu">
                            <li role="presentation">
                                <a role="menuitem" tabindex="-1" href="Home/ViewMain/Scottish Championship">
                                   English Premier League
                                </a>
                            </li>
                            <li role="presentation">
                                <a role="menuitem" tabindex="-1" href="Home/ViewMain/Scottish Championship">
                                   English Championship
                                </a>
                            </li>
                        </ul>
                </li>
            </ul>
           // @*@Html.MvcSiteMap().Menu(false, true, true, true, true)
            @Html.MvcSiteMap().SiteMapPath()*@


            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav"></ul>
            </div>

</div>

看起来它采取从一个我已经在我的+链接,在这里为我真正想要的是一个绝对路径的href相对路径?

Answer 1:

添加“/”您的URL开始

/Home/ViewMain/Scottish ChampionShip

它始终是更好地使用

@Url.Action("MethodName", "Controller")

<a href="@Url.Action("MethodName", "Controller")"> Test</a>

要通过在URL中的参数

  <a href="@Url.Action("MethodName", "Controller", new {LeagueName = "Scottish Premiership"})"> Test</a>


文章来源: Bootstrap DropDown menu doesn't work after first click