我有一个Rails应用程序。我用yarn安装了fullPage.js库。该库位于node_modules中。
如何加载我的应用程序中的文件?我在尝试:
<link rel="stylesheet" type="text/css" href="fullpage.css" />
这不起作用。我明白了:
获取http://localhost:3000/fullpage.css 404(未找到)
我试图在application.js中的application.scss中导入这个文件。
我试图把整个路径:
<link rel="stylesheet" type="text/css" href="node_modules/fullpage.js/dist/fullpage.css" />
要么
<link rel="stylesheet" type="text/css" href="/node_modules/fullpage.js/dist/fullpage.css" />
但我无法设法加载该文件。有人可以帮我理解,如何从Rails应用程序中的文件夹node_modules加载文件?
谢谢。
在application.css中添加它:
*= require fullpage.js/dist/fullpage
在加载资源时,Rails已经在node_modules
目录中查找,所以你应该省略它。