【问题标题】:Bootstrap-sass not loadingBootstrap-sass 未加载
【发布时间】:2017-02-02 23:44:58
【问题描述】:

Bootstrap 没有为我加载。我做错了什么?

application.scss(完整文件,没有其他内容)

// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables"
@import "bootstrap-sprockets";
@import "bootstrap";
@import "bootstrap/theme";

宝石文件

gem 'bootstrap', '~> 4.0.0.alpha4'
gem 'bootstrap-sass', '~> 3.1.1'
gem 'bootstrap-sass-extras'

HTML IN HEADER SHOWS(运行 rails s,处于开发模式):

<link rel="stylesheet" media="all" href="/stylesheets/application.css">

【问题讨论】:

  • 试试bootstrap/scss/bootstrap
  • 是的,不起作用。
  • 为什么你包含 3 个不同的宝石,只是 gem 'bootstrap-sass', '~&gt; 3.1.1' 对你有用?
  • 在未加载时继续添加它们。我从 gem 'bootstrap-sass-extras' 开始,只是删除了 bootstrap,但仍然无法正常工作。

标签: ruby-on-rails twitter-bootstrap ruby-on-rails-4 sass rubygems


【解决方案1】:

你试过了吗:

rails generate bootstrap:install static

rails generate bootstrap:install less

【讨论】:

  • 是的,再次运行“rails generate bootstrap:install static”,但还是不行。
  • config.rb文件的路径是什么?,我看到一个config.ru文件
【解决方案2】:

根据您提供的信息,这有点难以追踪。您是否已将样式文件重命名为 .scss 扩展名?确保您遵循文档中的安装说明:Bootstrap 4 alpha.

您似乎正在使用不需要的额外宝石。如果你使用的是 alph 4 版本的 bootstrap,你只需要在你的 gem 文件中,你不需要版本 3。确保在你的 application.js 文件中包含正确的依赖项:

//= require jquery
//= require bootstrap-sprockets

还有:

@import "bootstrap";

在您的 application.scss 文件中。

您必须配置这些文件,然后确保重新启动应用程序才能使更改生效。希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-20
    • 1970-01-01
    • 1970-01-01
    • 2017-01-07
    • 2013-10-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多