首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VuetifyJS中的默认字体已部分更改

VuetifyJS中的默认字体已部分更改
EN

Stack Overflow用户
提问于 2019-09-05 01:40:38
回答 3查看 1.7K关注 0票数 1

我使用的是Vuetify 2.0.14。我在Change Default Font in Vuetify上关注了这篇文章,并从@tzahi leh获取了解决方案。但是我看到网页被我的自定义字体部分改变了。我知道Vuetify有默认的Roboto字体,我想改成'Ubunut‘。我还下载了Ubuntu字体系列并将其放在assets/fonts文件夹中。

我的App.vue Style Content

代码语言:javascript
复制
<style lang="scss" scoped>
$typoOptions: display-4 display-3 display-2 display-1 headline title subtitle-1 subtitle-2 body-1 body-2 caption overline;

%font-choice {
  font-family: "Ubuntu", sans-serif !important;
}

@mixin md-typography {
  @each $typoOption in $typoOptions {
    .#{$typoOption} {
      @extend %font-choice;
    }
  }
}

.v-application {
  // font-size: 12px;
  @extend %font-choice;
  @include md-typography;
}

@font-face {
  font-family: "Ubuntu";
  font-style: normal;
  font-weight: 400;
  src: local("Ubuntu"), local("Ubuntu"),
  url("~@/assets/fonts/Ubuntu-R.ttf") format("ttf");
}
</style>

输出页面看起来像bwlow。红色突出显示仍然显示为Roboto字体样式,而其他字体则更改为Ubuntu字体样式。

我注意到display-4 display-3 display-2 display-1 headline title subtitle-1 subtitle-2 body-1 body-2 caption overline的样式与自定义样式字体的行为不同。

有关于如何在整个网站上完全更改为我的自定义字体的帮助吗?请

EN

回答 3

Stack Overflow用户

发布于 2019-09-29 15:53:51

最佳方式

定义(如果使用google字体)

代码语言:javascript
复制
@import url('https://fonts.googleapis.com/css? family=Oxygen:300,400,700&display=swap');
@import url('https://fonts.googleapis.com/css? family=Comfortaa&display=swap');

$body-font-family: 'Oxygen';
$title-font: 'Comfortaa';

用于证明2+

代码语言:javascript
复制
.v-application {
   font-family: $body-font-family, sans-serif !important;
    .title { // To pin point specific classes of some components
       font-family: $title-font, sans-serif !important;
    }
 }

请注意,由于.title .heading .subheading**.**和.heading通常使用不同的字体(显示字体),因此和and的声明是不同的

将其写入您的app.vue或直接导入到app.vue的单独的scss/css文件中。

对于app.vue脚本中的vuetify 1.5.x,添加

代码语言:javascript
复制
.application {
  font-family: "Font Family Name";
}
.headline,
.title,
.subheading{
     font-family: $body-font-family !important;
}

例如,如果您使用的是google字体,则脚本标记应如下所示

代码语言:javascript
复制
<style lang="scss">
@import url("https://fonts.googleapis.com/css?family=Questrial");

.application {
  font-family: "Questrial";
}
</style>
票数 1
EN

Stack Overflow用户

发布于 2019-09-06 15:52:17

<style lang="scss" scoped>中删除scoped

票数 0
EN

Stack Overflow用户

发布于 2019-10-10 13:14:19

在找了很长时间后,我找到了答案。

首先,你需要导入vuetify sass设置:

代码语言:javascript
复制
@import '~vuetify/src/styles/styles';

并将$body-font-family变量更改为您的字体系列

代码语言:javascript
复制
$body-font-family: Montserrat, sans-serif;

然后覆盖字体设置,如文档中的:Sass Variables

代码语言:javascript
复制
$headings: map-deep-set($headings, 'h1' 'font-family', $body-font-family);
$headings: map-deep-set($headings, 'h2' 'font-family', $body-font-family);
$headings: map-deep-set($headings, 'h3' 'font-family', $body-font-family);
$headings: map-deep-set($headings, 'h4' 'font-family', $body-font-family);
$headings: map-deep-set($headings, 'h5' 'font-family', $body-font-family);
$headings: map-deep-set($headings, 'h6' 'font-family', $body-font-family);
$headings: map-deep-set($headings, 'subtitle-1' 'font-family', $body-font-family);
$headings: map-deep-set($headings, 'subtitle-2' 'font-family', $body-font-family);
$headings: map-deep-set($headings, 'body-1' 'font-family', $body-font-family);
$headings: map-deep-set($headings, 'body-2' 'font-family', $body-font-family);
$headings: map-deep-set($headings, 'caption' 'font-family', $body-font-family);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57793387

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档