javascript_include_tag生成额外的HTML

时间:2014-01-03 21:59:59

标签: ruby-on-rails ruby-on-rails-4 asset-pipeline

在我的清单文件中,我有以下内容:

// 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
// 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_tree .

我的包含非常标准:

<%= javascript_include_tag "application.js", "data-turbolinks-track" => true %>

但由于某种原因,这是输出:

<script src="
  <script data-turbolinks-track="true" src="/landf/assets/application-f197c043b1bf438ab7beaa68751618f6.js"></script>

任何人都知道为什么要这样做?据我所知,我正在关注文档。谢谢你的帮助!

更新

如果我将该标记放在<head>中,则不会出现问题,但在</body>之前将其置于正确状态会导致问题。

2 个答案:

答案 0 :(得分:0)

嗨,你可以将你的javascript标签放在body标签下面的文件的末尾,它会加载得更快。检查放在下面是否不会导致问题

答案 1 :(得分:0)

结束了我正在运行不同资产的方法,导致初始脚本src损坏,导致多个脚本标记冲突。