vue-cli3.0項目中使用ttf字體

1、下載字體

此處下載的字體爲HYXinHaiXingKaiW.ttf

2、將下載好的字體放到項目的assets下,同時新建font.css文件

3、font.css中配置字體

@font-face {
    font-family: 'HYXinHaiXingKaiW';
    src: url('HYXinHaiXingKaiW.ttf');
    font-weight: normal;
    font-style: normal;
}

4、main.js中引入字體

5、在需要改變字體的地方使用

<div class='test'>字體測試代碼</div>
<style scoped>
    .test {
        font-family: 'HYXinHaiXingKaiW';
    }
</style>

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章