在子模板中加载脚本时,如何定义 Play 框架中 javascript 资源的加载顺序?
在我的 index.scala.html
中,我引入了 jQuery:
<script src="@routes.Assets.at("javascripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
在我的子模板中,我引入了一个依赖于 jQuery 的脚本:
<script src="@routes.Assets.at("javascripts/myScript.js")" type="text/javascript"></script>
但是,myScript.js
在“jquery-1.7.1.min.js”之前加载。
有什么建议吗?
最佳答案
您应该将脚本作为参数传递给您的 index.scala.html
。
但我推荐RequireJS . RequireJS 使您能够使用延迟加载。
关于javascript - Play 中的子模板 JS Assets 加载顺序!框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10808597/