如何使用 Visual Studio 2019 在 ASP.NET Core 2.2 中安装 Font Awesome [英] How to install Font Awesome in ASP.NET Core 2.2 using Visual Studio 2019

查看:48
本文介绍了如何使用 Visual Studio 2019 在 ASP.NET Core 2.2 中安装 Font Awesome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力寻找在 ASP.NET Core 2.2 中安装 Font Awesome 的任何最新安装指南

我尝试将文件手动导入到项目文件夹目录,然后尝试了 NuGet 包路径,但没有任何效果,因为我遵循的所有指南都参考了 2.2 中不存在的步骤和文件夹/文件

刚接触 ASP.NET Core 可能无济于事:(

解决方案

有很多方法可以实现这一点,但在我看来,快速启动和运行的最简单方法是 A.

答:获得一个 CDN 托管的字体真棒版本(它是免费的!)

  1. 前往Font Awesome - 开始并使用有效的电子邮件地址生成CDN 支持的工具包".莉>
  2. 您将收到一封带有CDN 嵌入代码"的电子邮件,它只是一个脚本标签.
  3. 将 Pasta 脚本标签复制到 _Layout 的脚本部分.

<块引用>

注意:您不会获得所有图标的智能感知,但是没有太多,我最终会在 font-awesome 的网站上直观地查找我想要的图标.如果您发现您确实需要智能感知或想要在断开连接的环境中使用 font-awesome,请参阅 B 部分.

B:一次安装"

  1. 前往Font Awesome - 下载并下载 zip 文件
  2. 将 zip 文件解压到 wwwroot/lib/
  3. 在您的 _Layout 中引用适当的内容.

 <环境包括=开发"><script src="~/lib/fontawesome-free-5.10.1-web/css/all.css"></script></环境><!-- ... ---><!-- JS--><环境包括=开发"><script src="~/lib/fontawesome-free-5.10.1-web/js/all.js"></script></环境>

<块引用>

注意:在这个例子中,我只为开发环境放置了对 Font Awesome 的 CSS 和 JS 引用,这意味着您仍然应该使用 A 部分,但将 CDN 版本放在生产"部分.

<script src="https://use.fontawesome.com/abcdef1234.js"></script></环境>

注意:abcdef1234.js 不是真正的文件,当您注册 CDN 包时,您将在电子邮件中获得您的特定文件

注意:CDN版本没有你需要添加的CSS文件,它被包裹在JS文件中.

终于

如果您确实需要比 ASP.NET Core 中包含的包更多的包,并且字体很棒,我强烈建议您通过@Tony Ngo 指出的包管理器和 LibMan 和任何开始都一样好.

I am struggling to find any up to date installation guide for installing Font Awesome in ASP.NET Core 2.2

I've tried a manual file import to the project folder directory, then tried the NuGet package route but nothing works because all the guides I follow make reference to steps and folders/files that don't exist in 2.2

Being new to ASP.NET Core is likely not helping the situation :(

解决方案

There are many ways to accomplish this, however in my opinion the easiest way to get up and running quickly is A.

A: Get a CDN hosted version of font awesome (it's free!)

  1. Head to Font Awesome - Start and generate a 'CDN powered kit' using a valid email address.
  2. You will receive an email with a 'CDN embed code', which is just a script tag.
  3. Copy Pasta the script tag into the scripts section of your _Layout.

Note: you will not get intellisense for all of the icons, however there isn't much to it, and I wind up visually looking up which icon I want on font-awesome's site anyways. If you find you really need the intellisense or want to work with font-awesome in a disconnected environment, see section B.

B: One time 'install'

  1. Head to Font Awesome - Download and download the zip file
  2. Extract the zip file to wwwroot/lib/
  3. Reference the appropriate in your _Layout.

    <!-- CSS -->
    <environment include="Development">
        <script src="~/lib/fontawesome-free-5.10.1-web/css/all.css"></script>
    </environment>

    <!-- ... --->

    <!-- JS -->
    <environment include="Development">
        <script src="~/lib/fontawesome-free-5.10.1-web/js/all.js"></script>
    </environment>

Note: In this example, I placed the CSS and JS reference to Font Awesome for the development environment only, which means you should still use section A, but place the CDN version inside the 'production' section.

<environment exclude="Development">
    <script src="https://use.fontawesome.com/abcdef1234.js"></script>
</environment>

Note: abcdef1234.js is not a real file, you'll get your specific file in the email when you sign up for the CDN package

Note: The CDN version does not have a CSS file you need to add, it's wrapped up in the JS file.

Finally

If you do need more packages than what is included with the ASP.NET Core and font awesome, I would highly recommend using moving to getting your libs through a package manager like @Tony Ngo pointed out, and LibMan is as good as any to start with.

这篇关于如何使用 Visual Studio 2019 在 ASP.NET Core 2.2 中安装 Font Awesome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆