[英]Grails application.js not executing
I have a Grails (2.3.6) app, and have included the asset-pipeline
plugin as a dependency. 我有一个Grails(2.3.6)应用程序,并且包含了
asset-pipeline
插件作为依赖项。 In my Config.groovy
: 在我的
Config.groovy
:
plugins {
// Lots of other stuff
compile ":asset-pipeline:1.8.7"
}
In myapp/web-app/js/application.js
(generated for me by Grails), I have only the following single line of code: 在
myapp/web-app/js/application.js
(由Grails为我生成)中,我只有以下一行代码:
alert("Hello!");
Then in my grails-app/views/index.gsp
: 然后在我的
grails-app/views/index.gsp
:
<html>
<head>
<asset:javascript src="application.js" />
</head>
<body>
...
</body>
</html>
When I do a grails run-app
, I don't see my JS alert(...)
statement fire. 当我执行
grails run-app
,我看不到我的JS alert(...)
语句触发。 Have I positioned my application.js
file incorrectly? 我的
application.js
文件放置不正确吗? Have I configured the asset-pipeline
plugin incorrectly? 我是否配置了
asset-pipeline
插件错误? Anything else I'm doing wrong? 我做错了什么吗? I just want to see my alert box!
我只想查看我的警报框!
Additionally, following the " put CSS at the top, and JS at the bottom " convention, I was wondering if anyone could chime in as to how I could reposition the application.js
to appear at the bottom of the <body/>
tag. 另外,遵循“ 将CSS放在顶部,而JS放在底部 ”的约定,我想知道是否有人可以将我重新放置
application.js
使其显示在<body/>
标记的底部。 My understanding was that asset-pipeline
assets only work inside of <head/>
. 我的理解是,
asset-pipeline
资产仅在<head/>
内部起作用。
Your static files go in grails-app/assets/. 您的静态文件位于grails-app / assets /中。 See organization for the details.
有关详细信息,请参见组织 。
According to the documentation for the asset-pipeline plugin your assets should be under the grails-app/assets/ directory structure. 根据资产管道插件的文档 ,您的资产应位于grails-app / assets /目录结构下。 Each type of asset is under a sub folder as follows:
每种资产都在子文件夹下,如下所示:
grails-app/assets/javascripts
grails-app/assets/images
grails-app/assets/stylesheets
Move your application.js
into the javascripts directory for asset-pipeline to pick it up. 将您的
application.js
移到javascripts目录中,以资产管道进行拾取。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.