gpt4 book ai didi

asp.net-core - Font Awesome 图标未显示在 ASP.NET CORE MVC 项目中

转载 作者:行者123 更新时间:2023-12-03 18:25:15 24 4
gpt4 key购买 nike

我正在开发一个 ASP.NET CORE MVC 应用程序,但在加载 Font Awesome 图标时遇到了问题。以下是文件夹布局:enter image description here

这是我的 _layout.cshtml 的样子:

<environment include="Development">
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.js"></script>
<link rel="stylesheet" href="~/lib/font-awesome/css/fontawesome.css" />
</environment>
<environment exclude="Development">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
asp-fallback-test="window.jQuery"
crossorigin="anonymous"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=">
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js"
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
crossorigin="anonymous"
integrity="sha384-xrRywqdh3PHs8keKZN+8zzc5TX0GRTLCcmivcbNJWm2rs5C8PRhcEn3czEjhAO9o">
</script>
<link rel="stylesheet" href="~/lib/font-awesome/css/fontawesome.min.css" />
</environment>
<script src="~/js/site.js" asp-append-version="true"></script>

@RenderSection("Scripts", required: false)

这是我尝试使用 fontawesome 图标的方式:
  <span class='input-group date datepicker'>
@Html.TextBoxFor(m => m.CandidateDetail.DateOfBirth, new { @id = "DateOfBirth", @class = "form-control" })
<span class="input-group-append">
<span class="input-group-text"><i class="fas fa-calendar"></i></span>
</span>
</span>

当我启动项目时,我看到的只是一个正方形。我在这里做错了什么?

最佳答案

供引用font-awesome ,您应该添加 ~/lib/font-awesome/css/all.css而不是 ~/lib/font-awesome/css/fontawesome.css .

将下面的代码添加到 <environment include="Development">

<environment include="Development">
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
<link href="~/lib/font-awesome/css/all.css" rel="stylesheet" />
</environment>

关于asp.net-core - Font Awesome 图标未显示在 ASP.NET CORE MVC 项目中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57275813/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com