如何使用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

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

问题描述

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

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

我尝试将手动文件导入到项目中文件夹目录,然后尝试使用NuGet软件包路由,但没有任何效果,因为我遵循的所有指南均引用了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

到ASP.NET Core可能无法解决这种情况:(

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.


  1. 转到字体令人敬畏-开始并生成'CDN

  2. 您将收到一封带有 CDN嵌入代码的电子邮件,它只是一个脚本标签。

  3. 将Pasta脚本标签复制到脚本部分

  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.




注意:您不会对所有图标都具有智能感知,但是没有没什么大不了的,无论如何,我最终都在视觉上查找我想要在font-awesome网站上的哪个图标。如果您发现您确实需要智能感知或想要在断开连接的环境中使用超赞的字体,请参阅B节。

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:一次安装



B: One time 'install'


  1. 前往很棒的字体-下载并下载zip文件

  2. 将zip文件提取到 wwwroot / lib /

  3. 在_Layout中引用相应的内容。

  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>




注意:在此示例中,我将CSS和JS引用放置到Font Awesome仅适用于开发环境,这意味着您仍应使用A节,但将CDN版本放在 production节中。

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>

注意: abcdef1234.js 不是真实文件,则在注册CDN软件包时会在电子邮件中获得您的特定文件

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

注意:CDN版本没有需要的CSS文件添加,将其包装在JS文件中。

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

如果您确实需要比实际更多的软件包我强烈建议您使用ASP.NET Core附带的字体和超棒的字体,通过@Tony Ngo之类的包管理器获取您的库,并且 LibMan 一样好就像任何开头一样。

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天全站免登陆