为什么用svg放弃了iconfont?
svg替代iconfont的好处(无论是基于Vue、Jquery),都推荐svg
http://www.woshipm.com/pd/463866.html
svg图标库,svg图标在线制作
https://icomoon.io/app/#/select
svg体积优化
https://jakearchibald.github.io/svgomg/?utm_source=next.36kr.com
示例代码(建议uniapp运行环境,修改也可以vue环境运行,需支持sass处理)
1 <template>
2 <view>
3 <view class="svg-list">
4 <view class="icon-facebook"></view>
5 <view class="icon-twitter"></view>
6 <view class="icon-feed"></view>
7 <view class="icon-youtube"></view>
8 </view>
9 </view>
10 </template>
11
12 <script>
13 export default {
14 data() {
15 return {
16
17 };
18 }
19 }
20 </script>
21
22 <style lang="scss">
23 $icons: google-plus,
24 facebook,
25 twitter,
26 feed,
27 youtube,
28 vimeo,
29 lanyrd,
30 forrst,
31 deviantart,
32 steam,
33 github,
34 wordpress,
35 blogger,
36 tumblr,
37 soundcloud,
38 linkedin,
39 lastfm,
40 delicious,
41 stumbleupon,
42 pinterest,
43 xing,
44 flattr;
45
46
47 .svg-list {
48 display: flex;
49 [class*="icon-"] {
50 margin: 2%;
51 }
52 }
53
54 [class^="icon-"] {
55 display: block;
56 width: 64upx;
57 height: 64upx;
58 text-indent: 100%;
59 overflow: hidden;
60 white-space: nowrap;
61 background: url(http://www.w3cplus.com/sites/default/files/blogs/2015/1506/sprite.svg) no-repeat;
62
63 @for $i from 1 through length($icons) {
64 &.icon-#{nth($icons,$i)} {
65 background-position: 0 -1 * (($i - 1) * 84upx);
66 }
67 }
68 }
69 </style>
来自大漠的一篇博文:https://www.w3cplus.com/svg/create-svg-sprite-sheet.html