加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 为什么= javascript_include_tag:默认在Rails

发布时间:2020-12-16 22:47:16 所属栏目:百科 来源:网络整理
导读:男人,WTH正在继续这个东西.你知道这条线实际上在Rails 3.1中吗? script src="/assets/defaults.js" type="text/javascript"/script 正如他们在ESPN上说的那样,“来吧,男人”. 我知道资产不再被视为二等公民.但是,似乎在这个候选人中,他们甚至无法获得绿卡.
男人,WTH正在继续这个东西.你知道这条线实际上在Rails 3.1中吗?
<script src="/assets/defaults.js" type="text/javascript"></script>

正如他们在ESPN上说的那样,“来吧,男人”.

我知道资产不再被视为二等公民.但是,似乎在这个候选人中,他们甚至无法获得绿卡.在新的app / assets / javascripts / application.js中:

// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here,but if you do,it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require_tree .

SOOOOO.我应该下载jquery吗我该怎么办?因为除了application.js之外的javascripts目录中没有任何东西.

加重.然而它是免费的,所以我怎么抱怨?无论如何,这些问题似乎非常基本,但我希望能提供任何帮助.

解决方法

在Rails 3.1中,不再有“默认值”,而是在application.js文件中指定的是“defaults”.您将使用此行包含此文件:
javascript_include_tag "application"

jquery和jquery_ujs文件带有默认的Rails 3.1 Gemfile中的jquery-rails gem.

该文件中的// = require行告诉Sprockets,您需要一个文件,在这种情况下,该文件将是jquery-rails中的jquery-rails,其中// = require_tree.将需要与application.js相同目录中的所有其他JavaScript文件,并将它们全部连接到一个文件中.

您可以阅读更多约the asset pipeline here.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读