需要提供后綴為.ttf的文件,打開在線字體生成器,上傳.ttf后,點(diǎn)擊立即生成荣茫,稍等一會(huì)之后,會(huì)下載壓縮包场靴,解壓后即可使用
將字體文件引入
-
自己定義一個(gè)文件夾计露,放入下載好的.ttf文件
image.png - 自己定義一個(gè)font.css文件,將下載好的字體文件的路徑引入
@font-face {
font-family: "NotoSans-SemiCondensed";
src: url('NotoSans-SemiCondensed.ttf');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: "NotoSans-SemiCondensedBold";
src: url('NotoSans-SemiCondensedBold.ttf');
font-weight: normal;
font-style: normal;
}
-
在App.vue中的style里引入
image.png - 在webpack的配置文件里要加上解析.ttf文件的規(guī)則
module: {
rules: [
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
}
-
使用
image.png