vue.js - Vuetify 字体在生产和开发中是不同的
问题描述
我注意到我部署的应用程序使用与开发应用程序不同的字体。我尝试了多种在部署的应用程序中设置字体的方法,但我将其默认设置为Roboto
. 我尝试过多种解决方案,但似乎没有一个能覆盖默认字体 CSS。
这是我SCSS
的App.vue
组件。
@font-face {
font-family: 'ITC Avant Garde Gothic Std Extra Light';
font-style: normal;
font-weight: normal;
src: local('ITC Avant Garde Gothic Std Extra Light'),
url('./fonts/ITCAvantGardeStdXLt.woff') format('woff');
}
$heading-font-family: 'ITC Avant Garde Gothic Std Extra Light';
$font-family: 'ITC Avant Garde Gothic Std Extra Light';
$body-font-family: 'ITC Avant Garde Gothic Std Extra Light';
$title-font: 'ITC Avant Garde Gothic Std Extra Light';
.v-application {
[class*='text-'] {
font-family: $font-family, 'ITC Avant Garde Gothic Std Extra Light' !important;
}
font-family: $font-family, 'ITC Avant Garde Gothic Std Extra Light' !important;
}
Chrome 中的开发 CSS
Chrome 中的生产 CSS
为所有元素设置默认字体的正确方法是什么?
解决方案
首先,您正在直接更改.v-application
课程,这是一种不好的做法。请使用官方方式使用 SASS 变量对其进行更改。这是链接。
$body-font-family: 'ITC Avant Garde Gothic Std Extra Light';
我知道您正在使用$body-font-family
,但我很确定变量不起作用,因为您已将它们添加到App.vue
SCSS 中。删除.v-application
类并正确遵循指南以使其正常工作。
在您的 src 目录中创建一个名为 sass、scss 或 styles 的文件夹,并使用名为 variables.scss 或 variables.sass 的文件。vuetify-loader 会自动将你的变量引导到 Vue CLI 的编译过程中,覆盖框架默认值。
推荐阅读
- ios - iOS 13 GM 上的 Google 登录失败
- c# - C# 表达式 if 语句,可能的扩展?
- excel - 按域名分隔不同列中的电子邮件地址
- reactjs - 当通过 url 调用第二个组件时,如何将道具从当前组件传递到另一个组件?
- android - 取消 onViewDetachedFromWindow 内特定 ViewHolder 的特定协程
- scala - 将整数映射到对象会出现错误“无法解析重载的构造函数”
- function - 在我的班级中初始化另一个班级时需要 1 个参数
- asp.net - 从 IIS 中的 wappalyzer 隐藏服务器信息
- laravel - Laravel 5.8 - 验证未来日期
- ruby-on-rails - Rails:如何根据 foriegn_key 自动循环创建项目