【问题标题】:How should look a application.scss file in ruby?在 ruby​​ 中应该如何看待 application.scss 文件?
【发布时间】:2023-03-20 21:14:01
【问题描述】:

我是 ruby​​ 新手,我的代码如下所示:这是正确的吗?我的 boostrap 没有加载..

所以application.scss

//= require . 
//= require_self
 //= require jquery
 //= require jquery_ujs
 //= require turbolinks
 //= require bootstrap
 //= require_tree .


@import "bootstrap-sprockets";
@import "bootstrap";

application.js 看起来像这样:

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require_tree .

感谢您的任何解释!

【问题讨论】:

  • 那些// require 行不属于application.scss。无论如何,这些都是 JavaScript 清单行。
  • *= 吗?在 scss 文件中?
  • application.css 更改为application.scss 后,您必须使用Sass @import 语句,而不是Rails 在资产清单文件中提供的默认CSS 注释语法。
  • 不客气。我知道它可能不能解决你的问题,但至少我可以教你。 :)
  • @ChrisPeters 也许你有解决这个问题的办法? stackoverflow.com/questions/31189115/…

标签: javascript ruby-on-rails ruby twitter-bootstrap


【解决方案1】:

在我们不包含 require 的 sass 文件中,您可以删除它们。将您的代码替换为如下

@import "bootstrap-sprockets";
@import "bootstrap";

【讨论】:

    猜你喜欢
    • 2021-04-17
    • 2017-05-04
    • 1970-01-01
    • 2019-06-27
    • 2010-11-21
    • 2011-10-10
    • 2011-03-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多