我正在尝试将Google字体添加到我的Rails 5.2应用程序中,但无法弄清楚为什么它不起作用/缺少了什么:
我在application.scss文件中添加了以下几行:
@import url('://fonts.googleapis.com/css?family=Lato:400,700,900&display=swap');
body {
padding-top: 70px;
font-family: 'Lato', sans-serif;
}
在application.scss中使用@import之前,我试图在application.html.erb中添加以下行
<link href="https://fonts.googleapis.com/css?family=Lato:400,700,900&display=swap" rel="stylesheet">
谢谢你的帮助!
似乎在application.scss的第一行中,有一个冒号(before //fonts
,after url('
)会导致错误。删除它可以解决此问题:
@import url('//fonts.googleapis.com/css?family=Lato:400,700,900&display=swap');
body {
padding-top: 70px;
font-family: 'Lato', sans-serif;
}
无需在应用程序中添加其他行,因为它将在您的scss文件中进行编译。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句