admin管理员组文章数量:1615195
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引入字体包 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1728705304a1170169.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论