新手问题 线上部署 js 引入问题

a167651202 · 2013年07月08日 · 最后由 wppurking 回复于 2013年07月08日 · 3424 次阅读

Nginx+ Unicorn+mysql 部署线上环境,在网页中我引入 js 文件

<script src="assets/js/jquery-1.9.1.min.js" type="text/javascript"></script>
        <script src="assets/js/modernizr.custom.js" type="text/javascript" ></script> 
        <script src="assets/js/jquery.scrollto.js"></script>
        <script src="assets/js/waypoints.min.js" type="text/javascript"></script>
        <script src="assets/js/jquery.tweet.js" type="text/javascript"></script>
        <script src="assets/js/custom.js" type="text/javascript"></script>
        <script src="assets/js/bootstrap.js"></script>
        <script src="assets/js/jquery.flexslider.js"></script>
        <script src="assets/js/jquery.fancybox.pack.js" type="text/javascript" ></script>
        <script src="assets/js/jquery.fancybox-media.js?v=1.0.0" type="text/javascript"></script>
         <script src="assets/js/retina.js"></script>

这样引入的,在本地测试环境下,一点问题都没有,到了线上我执行 预编译命令RAILS_ENV=production rake assets:precompile 以后,js 引用就不生效了,请问各位这是怎么回事。谢谢各位

你最好还要附上 app/assets/application.js 的内容看你怎么使用的 Assets pipline

不生效是什么意思

#2 楼 @Yujing_Z 就是没有成功调用这些 js 文件。

#1 楼 @wppurking

// 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 kindeditor
//= require_tree .

#1 楼 @wppurking 里面什么都没写。。

部署的是生产环境,都集成到一个 js 里面了

#6 楼 @Yujing_Z 请教如何引用呢?

#7 楼 @a167651202 //= require_tree . 这行代码,将你所有 app/assets/ 下的文件在 production 模式下压缩成为了一个 application.js 文件

可详细阅读一下 Manifest Files and Directives

Start Here - Asset Pipeline 也不太懂?!

需要 登录 后方可回复, 如果你还没有账号请 注册新账号