Introducing font icons in Vue
- Ali’s font icon library used in this article only explains how to import the Font class, and does not describe the other two: Unicode and Symbol.
download font icon
-
Ali's font icon library is used in this article, the address is: https://www.iconfont.cn/
-
Select the font icon you need and click Add to library
-
After the selection, click the logo of the shopping cart in the upper right corner to find all the font icons that have been added to the warehouse
-
Click to download the code
Font class way to use font icons
-
Unzip the downloaded download.zip package, open the Vue project that needs to import font icons, create an iconfont folder under the assets folder in the project, and copy the files in the downloaded download.zip package to iconfont
-
Import iconfont.css globally in the main.js of the Vue project, pay attention to the import path and make no mistakes
import './assets/iconfont/iconfont.css';
-
Add the following css styles to the App.vue global style
.icon, .iconfont { font-family: "iconfont" !important; font-size: 30px; font-style: normal; color: #1989fa; -webkit-font-smoothing: antialiased; -webkit-text-stroke-width: 0.2px; -moz-osx-font-smoothing: grayscale; }
-
In the class name of the html tag that needs to use the downloaded font icon, write the class name of the corresponding font icon, such as:
<div class="icon iconfont icon-yuqi"></div>
-
To view the class name of the downloaded font icon, you can go to the downloaded download.zip and open the demo_index.html web page to view it