我想在 React 中使用 Google 字体。我正在使用
import 'https://fonts.googleapis.com/css?family=Josefin+Sans';
在 App.js 和
font-family: 'Josefin Sans', cursive;
在 component.css 中,我收到编译失败错误。
最佳答案
据我所知,您无法从 URL 导入文件。您必须将其托管在本地(获取整个文件),或者将其包含在页面的标题中,就像使用另一个“基本”样式表一样。
编辑
在 component.css
中使用 @import
语法。
@import url('https://fonts.googleapis.com/css?family=Josefin+Sans');
迪伦
关于javascript - 如何在 React JS 中使用 Google 字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44708709/