vue 引入圖示庫

愛吃排骨發表於2018-07-09

1.開啟阿里相簿,建立一個專案,再去尋找自己想要的圖示,最後下載至電腦。

2.開啟下載的檔案包,如下圖


3.將裡面的部分檔案拷貝至你的專案中,在static 目錄下建立一個資料夾fonts,如下圖


4.開啟iconfont.css,往裡面新增程式碼如下,

[class^="icon"], [class*=" icon"]/*這裡有空格*/
{ font-family: "iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale; }

整體為下圖

@font-face {font-family: "iconfont";
  src: url('iconfont.eot?t=1530695918383'); /* IE9*/
  src: url('iconfont.eot?t=1530695918383#iefix') format('embedded-opentype'), /* IE6-IE8 */
  url('data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAeoAAsAAAAAC7QAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFZW7khyY21hcAAAAYAAAACIAAAB9GhgNsZnbHlmAAACCAAAA3kAAATo5JW55mhlYWQAAAWEAAAALwAAADYR5KfZaGhlYQAABbQAAAAcAAAAJAfeA4lobXR4AAAF0AAAABQAAAAgH+kAAGxvY2EAAAXkAAAAEgAAABIFMgOabWF4cAAABfgAAAAfAAAAIAEjAJBuYW1lAAAGGAAAAUUAAAJtPlT+fXBvc3QAAAdgAAAASAAAAF8h0nZgeJxjYGRgYOBikGPQYWB0cfMJYeBgYGGAAJAMY05meiJQDMoDyrGAaQ4gZoOIAgCKIwNPAHicY2Bk/ss4gYGVgYOpk+kMAwNDP4RmfM1gxMjBwMDEwMrMgBUEpLmmMDgwVDxrZm7438AQw9zA0AAUZgTJAQAutAz0eJzFkTEOg0AMBNeYAxSlyEPyET6RKo+go6Cj4pX7DbI+IyVI6VlrTvLqfD7ZAAoAF0/RArbBEFrlWvUdt+q3eCl/KOL+RGfhwJEzl33/6/zKauU3wnF06t/r5UZph8tk17U+617P95H1YjrQF+lJzJ8l0QT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hO+Ptvbw0tZedLPC2EXGylnDYIahs273WreLJ+UZWtFnaLY5QyP5GWKfxzvREd5vt6MbU2vUbuOHu9FP6+t4sDGYxl9kb8H0AjNcmN641v3s3+HTw2cKx4ftVjRptfHtaIL+BGy78GsAAAB4nGNgZGBgAOIS3Scn4/ltvjJwszCAwPWkje8Q9P89LAzMLkAuBwMTSBQAUngLvwB4nGNgZGBgbvjfwBDDwgACQJKRARVwAABHDgJxeJxjYWBgYH7JwMDCgB0DABrXAQkAAAAAAHYAyADeASoBagGoAnQAAHicY2BkYGDgYGhhEGQAASYg5gJCBob/YD4DABeNAbQAeJxlj01OwzAQhV/6B6QSqqhgh+QFYgEo/RGrblhUavdddN+mTpsqiSPHrdQDcB6OwAk4AtyAO/BIJ5s2lsffvHljTwDc4Acejt8t95E9XDI7cg0XuBeuU38QbpBfhJto41W4Rf1N2MczpsJtdGF5g9e4YvaEd2EPHXwI13CNT+E69S/hBvlbuIk7/Aq30PHqwj7mXle4jUcv9sdWL5xeqeVBxaHJIpM5v4KZXu+Sha3S6pxrW8QmU4OgX0lTnWlb3VPs10PnIhVZk6oJqzpJjMqt2erQBRvn8lGvF4kehCblWGP+tsYCjnEFhSUOjDFCGGSIyujoO1Vm9K+xQ8Jee1Y9zed0WxTU/3OFAQL0z1xTurLSeTpPgT1fG1J1dCtuy56UNJFezUkSskJe1rZUQuoBNmVXjhF6XNGJPyhnSP8ACVpuyAAAAHicbcFBDoAgDATALgKCvyx1NSSEQ6OJz/fg1RkJ8tnkX0HAgoiEjBUFVfBEdWp12qXzHMx+t0bP1t0G4+iT6VDjLvICXRUOwQ==') format('woff'),
  url('iconfont.ttf?t=1530695918383') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
  url('iconfont.svg?t=1530695918383#iconfont') format('svg'); /* iOS 4.1- */
}

.iconfont {
  font-family:"iconfont" !important;
  font-size:16px;
  font-style:normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
[class^="icon"], [class*=" icon"]/*這裡有空格*/
{ font-family: "iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale; }

.icon-area:before { content: "\e683"; }

.icon-rectangle:before { content: "\e603"; }

.icon-rubber:before { content: "\e67f"; }

.icon-circle:before { content: "\e608"; }

.icon-line:before { content: "\e605"; }

.icon-faced:before { content: "\e649"; }

5.在專案中運用

在main.js中引入 

import 'static/fonts/iconfont.css'

html裡面這樣使用它 

<i class="ico icon-rubber">
這樣我們就可以自定義自己想要的各種圖示了

相關文章