如何在VUE项目中使用导入的字体?
How to use imported fonts in a VUE project?
我正在开发我的第一个 vue 项目,并按照不同的示例和官方文档在本地项目中使用导入字体时无法解决错误。
在我的标签中,我导入了我想在组件中使用的字体,然后在使用它时引用它,它returns我在图像中附加的错误
<style scooped>
@font-face {
font-family: 'RalewayRegular';
src: local('RalewayRegular'),
url(../../fonts/Raleway-Regular.ttf) format('truetype');
font-style: normal;
}
body {
font-family: 'RalewayRegular';
}
.header {
display: flex;
justify-content: center;
align-items: baseline;
}
.menu {
list-style: none;
display: flex;
align-items: baseline;
}
.nav-item {
padding: 25px;
position: relative;
}
.nav-link:hover {
color: #666B74;
}
.menu-link-toggle {
cursor: pointer;
}
.dropdown-menu {
list-style: none;
position: absolute;
padding: 10px;
background-color: white;
width: max-content;
}
a {
font-size: 14px;
color: #D53865;
font-weight: bold;
letter-spacing: 1px;
text-decoration: none;
}
a:before {
content: '';
position: absolute;
width: 30%;
height: 3px;
bottom: 30%;
left: 35%;
background: #D53865;
visibility: hidden;
border-radius: 5px;
transform: scaleX(0);
transition: .25s linear;
}
a:hover:before,
a:focus:before {
visibility: visible;
transform: scaleX(1);
}
.added {
display: none;
}
</style>
有没有用过VUE的人可以帮帮我,告诉我我的错误是什么?
提前感谢您的时间和帮助
看起来像是 webpack 问题。你可能需要一个配置。
Check out this article
我正在开发我的第一个 vue 项目,并按照不同的示例和官方文档在本地项目中使用导入字体时无法解决错误。
在我的标签中,我导入了我想在组件中使用的字体,然后在使用它时引用它,它returns我在图像中附加的错误
<style scooped>
@font-face {
font-family: 'RalewayRegular';
src: local('RalewayRegular'),
url(../../fonts/Raleway-Regular.ttf) format('truetype');
font-style: normal;
}
body {
font-family: 'RalewayRegular';
}
.header {
display: flex;
justify-content: center;
align-items: baseline;
}
.menu {
list-style: none;
display: flex;
align-items: baseline;
}
.nav-item {
padding: 25px;
position: relative;
}
.nav-link:hover {
color: #666B74;
}
.menu-link-toggle {
cursor: pointer;
}
.dropdown-menu {
list-style: none;
position: absolute;
padding: 10px;
background-color: white;
width: max-content;
}
a {
font-size: 14px;
color: #D53865;
font-weight: bold;
letter-spacing: 1px;
text-decoration: none;
}
a:before {
content: '';
position: absolute;
width: 30%;
height: 3px;
bottom: 30%;
left: 35%;
background: #D53865;
visibility: hidden;
border-radius: 5px;
transform: scaleX(0);
transition: .25s linear;
}
a:hover:before,
a:focus:before {
visibility: visible;
transform: scaleX(1);
}
.added {
display: none;
}
</style>
有没有用过VUE的人可以帮帮我,告诉我我的错误是什么? 提前感谢您的时间和帮助
看起来像是 webpack 问题。你可能需要一个配置。 Check out this article