admin管理员组

文章数量:1615196

 1、先下载.ttf字体包New fonts | dafont这里有免费的

2、目录结构(可以自定义)

3、font.css代码 

:root{
    --color:red;
    --fontStyle:'hahha2';
}
/* @font-face {
    font-family: 'hahha';
    src: url('Blueberry Days.ttf');
    font-weight: normal;
    font-style: normal;
} */
@font-face {
    font-family: 'hahha2';/*这里属性值可以自定义,用的时候和定义的一致即可*/
    src: url('Pineapple Days.ttf')format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

}

4、引入的时候可在main.js或app.vue引入皆可,下面示例app.vue引入方式

@import '@/assets/font/font.css';
#app {
  // font-family: 'hahha','hahha2';
  font-family: var(--fontStyle);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: var(--color);
}

app.vue  scss形式引入注意路径 

$fontstyle:'hahha2';
$color:red;
@font-face {
    font-family: 'hahha2';
    /*这里属性值可以自定义,用的时候和定义的一致即可*/
    src: url('@/assets/font/Pineapple Days.ttf');
    font-weight: normal;
    font-style: normal;
}

本文标签: 字体vue