欢迎各位兄弟 发布技术文章
这里的技术是共享的
见下面的红色部分
@using Microsoft.EntityFrameworkCore
@using wzfzxx1.Data
@inject wzfzxx1Context _context;
@{
var categories = await _context.Category.ToListAsync();
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - wzfzxx1</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/wzfzxx1.styles.css" asp-append-version="true" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div>
@*<a asp-area="" asp-controller="Home" asp-action="Index">wzfzxx1</a>*@
<button type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index" >首页</a>
</li>
@foreach(var item in categories)
{
<li>
<a class="nav-link text-dark" asp-area="" asp-controller="Categories" asp-action="Detail" asp-route-id="@item.Id" >@item.Name</a>
</li>
}
</ul>
</div>
</div>
</nav>
</header>
<div>
<main role="main">
@RenderBody()
</main>
</div>
<footer class="border-top footer text-muted">
<div>
© 2022 - wzfzxx1 - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>