我应该在哪里把JavaScript库放在Grails应用程序中? [英] Where should I put javascript libraries in a Grails app?
问题描述
我有一些我自己的Javascript库,它们对我的HTML页面做了一些漂亮的处理,我想将它们包含在我的gsp页面中,特别是我的应用程序的着陆页。我曾尝试将它们放在 views
文件夹和 web-app / js
和 $ APP_HOME /脚本
但是当我加载我的index.gsp脚本不显示。
I have a couple of Javascript libraries of my own that do some nice prettyfying of my HTML pages and I want to include them in my gsp pages, particularly the landing page of my app. I have tried putting them in views
folder and web-app/js
and $APP_HOME/scripts
but when I load my index.gsp the scripts don't show up.
我也在我的代码中尝试了各种替代方法没有一个工作...
I have also tried a variety of alternatives in my code none of which work...
<script src="mylib.js" type="text/javascript"></script>
<script src="js/mylib.js" type="text/javascript"></script>
<script src="scripts/mylib.js" type="text/javascript"></script>
我确定有一种聪明的方法可以在飞行中实现这一点,但我真的只是想要一个位置,我可以放置一些可以在我的应用程序中使用的样板代码。在约定配置的基础上,预期的做法是什么?
I'm sure there is a clever grails way of doing this on the fly, but I really just want a location where I can place some boilerplate JavaScript code that I can use in my app. With convention over configuration in mind, what is the expected practice?
推荐答案
我应该考虑在你的布局中放置web-app / js / myLib.js ,放置< g:javascript library =myLib/>
成为你需要的东西。
With your JS file at: web-app/js/myLib.js
, putting <g:javascript library="myLib" />
in your layout should I think be what you need.
这篇关于我应该在哪里把JavaScript库放在Grails应用程序中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!