如何在VUE项目中使用导入的字体?

问题描述

我正在开发我的第一个vue项目,并遵循不同的示例和官方文档,在本地项目中使用导入的字体时我无法解决错误

console error

在我的标签中,导入要在组件中使用的字体,然后在使用它时引用它,它返回我在图像中附加的错误


<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