在这里推荐一个图标库,写前端可用上
https://www.iconfont.cn/home/index?spm=a313x.7781069.1998910419.2
1.先在index.html中配置:在<head>后加如下代码
<script src="//at.alicdn.com/t/font_3157290_rizszwyrvya.js"></script>
2.在Home中加入一下代码
<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-31liebiao"></use>
</svg>
3.下载px转化rem的插件,安装后点“小齿轮”,进入“扩展设置”,把默认16改为50即可
4.App.vue中去掉不需要的部分,并更改图标样式,代码如下
<template>
<router-view/>
</template>
<style lang="less">
*{
margin: 0;
padding: 0;
box-sizing: border-box; // 用盒子,设置内边距后不会撑开
}
.icon{
width: .4rem; // 代表0.4*50px=20px
height: .4rem;
}
</style>
5.发现图标大小展示如下,说明图标设置成功