gpt4 book ai didi

grails - Grails负载r:需要

转载 作者:行者123 更新时间:2023-12-02 15:00:49 24 4
gpt4 key购买 nike

在我的ApplicationResources.groovy中,我有

modules = {
common {
dependsOn('jquery')
resource url: 'js/jquery.datetimepicker.js'
resource url: 'css/jquery.datetimepicker.css'
}
}

而我的index.gps就是这样
<r:require modules="common"/>

在我的layout.gsp中:
<r:layoutResources/>

但这给了我这个错误:当我使用 Uncaught TypeError: Object [object Object] has no method 'datetimepicker'
<script>
$('#datetimepicker').datetimepicker();
</script>

而另一个错误是当我使用 It looks like you are missing some calls to the r:layoutResources tag. After rendering your page the following have not been rendered: [defer]时:
<r:script>
$('#datetimepicker').datetimepicker();
</r:script>

我对r:script vs script感到困惑。有什么我想念的吗?在检查时,仅加载jquery和css。

最佳答案

您需要在布局GSP中使用两个单独的<r:layoutResources/>实例,一个实例恰好在</head>之前,另一个恰好在</body>之前。第一个将以“head”方式呈现资源,第二个将以“defer”呈现资源。

由于layoutResources标签位于头部/ body 的末尾,因此生成的脚本标签或CSS链接将出现在您定义的任何普通<script>之后。但是,在<r:script>呈现了<r:layoutResources/>请求的资源之后,它将在适当的配置中排队等待<r:require>输出。

关于grails - Grails负载r:需要,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22871555/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com