我有一些带有一些项目的bootstrap导航栏,但是当我点击它时,没有任何反应。在Chrome的控制台中,没有显示任何错误。
我在bootstrap site要求时添加了标签。
有人知道出了什么问题吗?
以上是我的_Layout.cshtml代码:
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>p.align{padding-left: 2em }</style>
<title>@ViewData["Title"] - PakaPaka Store</title>
<environment include="Development">
<link rel="stylesheet" href="~/Content/site.css"/>
</environment>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css"
integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light">
<a class="navbar-brand"> <img src=@ViewBag.Logo height="50"></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-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">
<li class="nav-item active">
<a class="nav-link" asp-controller="Site" asp-action="Index">Home<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" asp-controller="Dash" asp-action="Products">Produtos</a>
</li>
<li class="nav-item">
<a class="nav-link" asp-controller="Site" asp-action="Contact">Contato</a>
</li>
</ul>
</div>
</nav>
<div class="container body-content">
@RenderBody()
<footer>
<hr />
<p class="align">
<a href="https://www.instagram.com/pakapaka.store/">
<i class="fab fa-instagram fa-lg"></i>
</a>
<a href="https://www.facebook.com/pakapaka.store/">
<i class="fab fa-facebook-square fa-lg"></i>
</a>
</p>
<p class="align">© 2018 - Desenvolvido por: Hatsumi Higuchi Hashinaga</p>
</footer>
</div>
<environment include="Development">
<script src="~/Content/site.js" asp-append-version="true"></script>
</environment>
@RenderSection("Scripts", required: false)
<!-- Bootstrap -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
</body>
答案 0 :(得分:1)
您正在采用的方式是.Net Core方式。使用.Net Framework,您可以使用特定语法来定义控制器的链接,如下所示:
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Início", "Index", "Home")</li>
<li>@Html.ActionLink("Sobre", "About", "Home")</li>
<li>@Html.ActionLink("Contato", "Contact", "Home")</li>
</ul>
有关详情,请查看docs。