20
在我的application.js文件,我有:Rails指定JavaScript文件的加載順序?
//= require jquery
//= require jquery_ujs
//= require underscore
//= require backbone
//= require_tree .
//
//= require .//community_app
//
//= require_tree ../templates/
//= require_tree .//models
//= require_tree .//collections
//= require_tree .//views
//= require_tree .//routers
,但生成的HTML不服從這個命令:
<head>
<title>CommunityApp</title>
<link href="/assets/application.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/communities.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/home.css?body=1" media="all" rel="stylesheet" type="text/css" />
<script src="/assets/jquery.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
<script src="/assets/underscore.js?body=1" type="text/javascript"></script>
<script src="/assets/backbone.js?body=1" type="text/javascript"></script>
<script src="/assets/collections/communities.js?body=1" type="text/javascript"></script>
<script src="/assets/community_app.js?body=1" type="text/javascript"></script>
<script src="/assets/home.js?body=1" type="text/javascript"></script>
<script src="/assets/models/community.js?body=1" type="text/javascript"></script>
<script src="/assets/application.js?body=1" type="text/javascript"></script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="ktrLMDYSJaU/mmgmzfpxDfMin7OCXga4K5gVIJZHJUI=" name="csrf-token" />
</head>
<body>
收藏這使我的錯誤在前面的模型之前加載-結束。我怎樣才能讓它以特定的方式加載js文件? 感謝
感謝您的輸入。有沒有一種方法可以讓require_tree不按字母順序加載?什麼是正確的方法來做到這一點? – 0xSina
@ 0xSina:指定特定順序的正確方法是,像你(幾乎)那樣手動指定順序。 –
我想刪除'require_tree .',並按照需要的順序(可能在子文件夾中使用require_tree)請求事物 –