天天看點

vue中引入第三方字型

  在實際開發中,預設字型無法滿足我們的需求,這時候就需要依賴第三方字型庫,這裡推薦一個我使用的字型庫:fonts2U。

1、下載下傳一個字型包,一般包含如下檔案

vue中引入第三方字型

多種格式的檔案是為了适配不同浏覽器環境

2、配置stylesheet檔案,一般下載下傳下來的已經配置好了,自己如果有特殊需要可以修改

@font-face {
    font-family: "Curvic";
    src: url("CURVIC__.eot?") format("eot"),
         url("CURVIC__.woff") format("woff"),
         url("CURVIC__.ttf") format("truetype"),
         url("CURVIC__.svg#Curvic") format("svg");
    font-weight: normal;
    font-style: normal;
}
           

3、vue中引入stylesheet

<style lang="scss">
    @import "../common/font/stylesheet.css";
    .word {
        font-family: "Curvic";
    }
</style>
           

至此第三方字型就引入成功了,你可以實作各種炫酷的字型。