stylesheet_link_tag 与 Bootstrap 一起使用 [英] stylesheet_link_tag together with Bootstrap

查看:35
本文介绍了stylesheet_link_tag 与 Bootstrap 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想按照教程在 Rails 5.1.5 上设置 Bootstrap https://www.railstutorial.org/book/filling_in_the_layout 但使用 Gemfile 的过程不起作用.

I'd like to set Bootstrap on Rails 5.1.5, following the tutorial https://www.railstutorial.org/book/filling_in_the_layout but the procedure with the Gemfile won't work.

经过一些阅读,特别是这里:在 Rails 应用程序上安装 Bootstrap 3 我最终下载了 css 文件并将它们直接复制到 app/assets/stylesheets 中.

After some readings, in particular here: Installing Bootstrap 3 on Rails App I ended up downloading the css files and copying them directly in app/assets/stylesheets.

现在我收到此错误:

Invalid CSS after "...quire bootstrap": expected "{", was ""

链接到 application.html.erb 中的这一行

linked to this line in application.html.erb

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>

据我所知,这一行是用我在 app/assets/stylesheets(那里有一个文件 application.css)中创建的 application.scss 文件处理的.这个文件只有一行:

As I understand, this line is processed with the application.scss file that I have created in app/assets/stylesheets (where there was a file application.css). This file has only one line:

*= require bootstrap

在进一步查看文档后,我做了一个测试:

After looking further in the docs, I have made a test with:

<%= stylesheet_link_tag "bootstrap" %>

从那里我得到另一个错误:

and from there I get another error:

TypeError: Cet objet ne gère pas cette propriété ou cette méthode

这意味着'这个对象不处理这个方法'.

which means 'this object doesn't deal with this method'.

只是我的 Rails 安装的另一个错误配置还是什么?

Just another misconfiguration of my Rails installation or what ?

nodeJS 安装有可能解决问题吗?我在这里找到了回复 Ruby on rails: Stylesheets not working ExecJS::ProgramError 似乎已经做到了.

Is it possible that a nodeJS installation solve the problem ? I've found a reply here Ruby on rails: Stylesheets not working ExecJS::ProgramError which seems to have made it.

推荐答案

实际上安装 NodeJS 有很大帮助:这应该是窗口用户要做的第一件事!

Actually installing NodeJS can help a lot: this should be the very first thing to do for window users!

这篇关于stylesheet_link_tag 与 Bootstrap 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆