PrefaceMany years ago, I was a newbie on the server side, but as the industry became more competitive, I was forced to become a newbie on the front end. . . Just kidding, I just like learning technology! This chapter will lead you to open Alibaba Iconfont Library in another high-end way. In the past, we either had to spend a lot of effort on the Internet to find some icon pictures to beautify our web pages. However, with the development of technology and the technical contributions of some large platforms, we have to say that Alibaba is still awesome. This is not to praise it or advertise it. Indeed, they do better than Tencent in some fields. It may be related to the field. Due to my personal cognitive level, I can only think so. For example, in the direction of our JAVA server, Alibaba has some open source technologies such as Nacos, Canal, RocketMQ, Dubbo, and Sentinel. Back to the topic. As the title suggests, the content of this chapter revolves around the VUE front-end and the Ali Iconfont icon library. After going through the era of piecing together icons from the website, I started to use the Ali Iconfont icon library around 2015-2016. At the beginning, I only knew how to download icons for use, as follows This is a downloaded picture, which is quite lol. Later, with the learning of front-end technology, I began to learn how to use icon file applications when I wrote uniapp. If the icons are frequently changed, you will need to frequently download the icon files and re-import them, which is troublesome. In this chapter, we will introduce the Ali Iconfont icon library online to dynamically load it. This method does not require downloading icon icons or icon files. I personally feel that the most convenient thing is that the icon library can be dynamically updated! And even if we delete the project group in the Ali Iconfont icon library, as long as the connection has been generated, it can still be used in the project, but I don’t know how long the connection recovery time is! Start using IconfontOfficial Website Iconfont Select Icon Add to Project Get the link So far, the Iconfont platform related operations are completed. Next is the convenient operation of VUE Online call testindex.html introduces the link <link rel="stylesheet" href="//at.alicdn.com/t/font_2872687_x5kgx7w5eth.css" rel="external nofollow" > Interface Usage <i class="iconfont icon-3column"></i> Effect View Testing completed! VUE project integrationWrite a tool to add head /** * Dynamically insert css */ export const loadStyle = url => { const link = document.createElement('link') link.type = 'text/css' link.rel = 'stylesheet' link.href = url const head = document.getElementsByTagName('head')[0] head.appendChild(link) } This is to help us add the link tag in the head, the effect is as follows main configuration <br /> Import and load link tool import { loadStyle } from './utils/util' Initialize iconfont connection let iconfontVersion = ['2872417_3u9w2bdk2b']; const iconfontUrl = `//at.alicdn.com/t/font_$key.css` The reason why $key is used here is that if we have multiple icon items, we can add multiple to the iconfontVersion array. Write a replacement $key connection method and call the add link tool method // Dynamically load Alibaba Cloud font library iconfontVersion.forEach(ele => { console.log(iconfontUrl.replace('$key', ele)) loadStyle(iconfontUrl.replace('$key', ele)) }) Complete code Icon Usage <i class="iconfont icon-3column"></i> <i class="iconfont icon-column-4"></i> Effect display Here we need to write iconfont in the i tag, so we can optimize it Optimize iconfont // About icon CSS settings [class^="icon-"] { font-family: "iconfont" !important; /* The following content refers to the rules of the third-party icon library itself*/ font-size: 18px !important; font-style: normal; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } .avue-input-icon__item i, .avue-crud__icon--small { font-family: "iconfont" !important; /* The following content refers to the rules of the third-party icon library itself*/ font-size: 24px !important; font-style: normal; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } .el-menu-item [class^=icon-] { margin-right: 5px; width: 24px; text-align: center; font-size: 18px; vertical-align: middle; } .el-submenu [class^=icon-] { vertical-align: middle; margin-right: 5px; width: 24px; text-align: center; font-size: 18px; } Global References import './styles/common.scss' Effect View Done This is the end of this article about VUE calling Ali Iconfont icon library online. For more relevant content about VUE calling Ali Iconfont icon library, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Super simple implementation of Docker to build a personal blog system
>>: Mysql get table comment field operation
1. Common MySQL configuration All the following c...
Preface When writing front-end pages, we often us...
Detailed analysis of SQL execution steps Let'...
The basics of MySQL knowledge points for the seco...
Difference between HTML and XHTML 1. XHTML elemen...
Preface: Jenkins' Master-Slave distributed ar...
Table of contents Preface 1. Null coalescing oper...
If there are any errors in this article or you ha...
Preface This article mainly introduces the releva...
1.MySQL UPDATE JOIN syntax In MySQL, you can use ...
Table of contents 1. In project development, the ...
1. Enter the host machine of the docker container...
1. MySQL download address; http://ftp.ntu.edu.tw/...
VirtualBox is a free and open source virtualizati...
Generally speaking, when we view the contents of ...