在Vue项目中修改字体,可以通过以下几种方式进行:
全局样式文件
:
在项目的全局样式文件中(通常是
App.vue
或
main.js
中引入的CSS文件),使用
@font-face
规则来引入字体,然后通过类名或直接在元素上使用该字体。
/* 在全局样式文件中 */
@font-face {
font-family: ‘MyCustomFont’;
src: url(‘path/to/font-file.woff2’) format(‘woff2’),
url(‘path/to/font-file.woff’) format(‘woff’);
font-weight: normal;
font-style: normal;
}
/* 使用字体 */
body {
font-family: ‘MyCustomFont’, sans-serif;
}
CSS类
:
在组件的