1.将下载好的字体文件添加到项目src/assets/fonts目录下(通常是.ttf或.otf格式)
微信截图_20240409144902.png
2.在Vue项目的样式文件中通过@font-face规则引入字体。
@font-face {
font-family: 'MyCustomFont';
src: url('./assets/fonts/MyCustomFont.ttf') format('truetype'); /* 修改为相对应的字体文件路径 */
font-weight: normal;
font-style: normal;
}
3. 使用新字体
body {
font-family: 'MyCustomFont', sans-serif;
}