Or directly use the fonts that come with windows:
C:\Windows\Fonts
Put the downloaded ttf file in the src/assets/font folder
font.css:
@font-face {
font-family: "Sunday April";
src: url('Sunday April.ttf');
}
@font-face {
/* 自定义的字体名车,调用该字体时使用 */
font-family: "Smiley_Sans_Oblique_斜体";
/* 引用字体包。.ttf后缀不区分大小写,用.TTF也可以 */
src: url('Smiley_Sans_Oblique_斜体.ttf');
font-weight: normal;
font-style: normal;
}
Introduced in main.ts:
import "@/assets/font/font.css";
test:
<h1 style="font-family: 'Smiley_Sans_Oblique_斜体'">test字体</h1>
Effect:
For the following fonts, they can be used directly in CSS without importing:
A complete list of fonts supported by Chrome http://www.dve2.com/t/9