Article directory
foreword
In the process of using uniapp
the development project, the use of icons can be said to be a daily operation, even 80% of the pages will be used, and if the ui framework is used, the framework itself will also have its own icons, but these icons are very Difficult to meet the demand, the following is the use of the Ali icon.
Find the icon you need
- Add the icons you need to the shopping cart or bookmark them
- Click on the shopping cart icon in the upper right corner to add the selected icon to the item
- You need to log in here, you can Baidu by yourself
Download to local
After downloading locally
- You can click
demo_index.html
to view, there are usage methods inside.
used in the page
Copy all the downloaded files to the project. It is recommended to put them static/iconfont
in the folder. You can copy all of them, or just copy iconfont.css
and iconfont.ttf
two files.
Create a local css file
common/css
Create a file under the file ,font-icon.css
this is to configure and reference Ali's icon, the code is as follows:- Copy the contents of iconfont.css into this file, just copy the style below .iconfont, and the import above does not need to be copied.
- There may be some searched by small partners that need to be added
https
, but now the official has processed it, so it is not necessary. If you cannot access it, you can add it at the end.
@font-face {
font-family: uniicons;
font-weight: normal;
font-style: normal;
src:url('~@/static/iconfont/iconfont.ttf') format('truetype');
}
.icon {
color: #999;
font-family: uniicons;
font-size: 42upx;
font-weight: normal;
font-style: normal;
line-height: 1;
display: inline-block;
text-decoration: none;
-webkit-font-smoothing: antialiased;
}
// 下面的内容,把iconfont.css里的内容复制过来,复制 .iconfont 下面的样式即可。
Introduced in app.vue
page use
demo_index.html
There are corresponding icons to use in- Just replace
demo_index.html
the class in the page with , because you define this in , and you can also use the same name or customize the name in order to distinguish it.iconfont
icon
font-icon.css
<span class="icon"></span>
<span class="icon icon-xxx"></span>
Use in the navigation bar
- Select the icon and download it locally without creating a css file to import it, just use it directly.
- The use of the navigation bar is also the same, just follow the uniapp official website.
- It’s just that the online part also said that it was added at the place where it was introduced
https
. It should be the previous versionhttps
. text
The value of in the code can be found in , justdemo_index.html
replace the previous symbol with , remember that there is no semicolon behind\u
"app-plus": {
"titleNView": {
"buttons": [{
"text": "\ue600",
"fontSrc": "/static/iconfont/iconfont.ttf",
"float": "right",
"key": 1
},
{
"text": "\ue648",
"fontSrc": "/static/iconfont/iconfont.ttf",
"float": "right",
"key": 2
}
]
}
}
summary
- Although the article is relatively long, it is not as concise as others, but the usage process is like this, so it is convenient for everyone to customize various icons
- How to use, in fact, there are official websites, please pay attention to develop according to the official
- This article is to guide and sort out, there are many ways, everyone thinks it is applicable