【问题标题】:Integrate bootstrap in grails在 grails 中集成引导程序
【发布时间】:2015-07-11 04:00:30
【问题描述】:

我是 grails 的新手,我正在尝试集成 bootstrap,但我在标签 r 中有错误:我正在尝试找到一些很好的教程来将 bootstrap 集成到 grails 中,但我找不到任何东西,和任何好的解决方案。

我在 BuildConfig 中添加(我可以看到引导程序安装在我的 link_to_grails_plugins 中)

compile ":twitter-bootstrap:3.3.4"

我也是这样:

“要包含引导资源,请将以下内容添加到应用程序的 css 或 js 文件中。”

Javascript grails-app/assets/javascripts/application.js:

//= require bootstrap

console.log("My javascript goes here");
Stylesheet grails-app/assets/javascripts/application.css:

/*
*= require bootstrap
*/

还有这个.... 布局

你的 grails-app/views/layouts/main.gsp:

<!DOCTYPE html>
<html>
<head>
    <title><g:layoutTitle default="Grails"/></title>
    <asset:stylesheet src="application.css"/>
    <g:layoutHead/>
</head>
<body>
    <g:layoutBody/>
    <asset:javascript src="application.js"/>
</body>
</html>

但是当我把我的观点放在:

<html>
    <head>
        <meta name="layout" content="main"/>
        <r:require modules="bootstrap"/>
    </head>
<body>
    <h1> Hello World </h1>
</body>
</html>

&lt;r:require modules="bootstrap"/&gt; 标记为黄色,我可以读取未知标签 (r:require)。

【问题讨论】:

  • &lt;r:require /&gt; 来自资源插件。对于当前版本的 grails,asset-pipeline 是提供资产的默认插件。这就是为什么你的 IDE 不知道这个标签的原因。使用资产管道时,您可以将其删除,因为&lt;asset:stylesheet src="application.css"/&gt; 已经成功了。在您自己的答案中,您两次声明引导程序-我认为这不是一个好主意。您必须决定依赖范围 - compileruntime

标签: twitter-bootstrap grails


【解决方案1】:

我找到了解决方案。您必须在 BuildConfig.groovy 中添加:

运行时':twitter-bootstrap:3.3.4'

我展示了你必须在插件中拥有的所有代码:

plugins {
        // plugins for the build system only
        build ":tomcat:7.0.55"

        // plugins for the compile step
        compile ":scaffolding:2.1.2"
        compile ':cache:1.1.8'
        compile ":asset-pipeline:1.9.9"
        compile ":twitter-bootstrap:3.3.4"

        // plugins needed at runtime but not for compilation
        runtime ":hibernate4:4.3.6.1" // or ":hibernate:3.6.10.18"
        runtime ":database-migration:1.4.0"
        runtime ":jquery:1.11.1"
        runtime ':twitter-bootstrap:3.3.4'

        // Uncomment these to enable additional asset-pipeline capabilities
        //compile ":sass-asset-pipeline:1.9.0"
        //compile ":less-asset-pipeline:1.10.0"
        //compile ":coffee-asset-pipeline:1.8.0"
        //compile ":handlebars-asset-pipeline:1.3.0.3"
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-03
    • 1970-01-01
    • 2018-11-26
    • 2015-07-26
    • 2017-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多