在grails 3 app中,什么是微调器,我需要application.js吗?

问题描述 投票:0回答:1

grails 3附带bootstrap 3.我想基于grails 4创建自己的main.gsp布局,即用以下内容替换默认的main.gsp:

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <asset:link rel="icon" href="favicon.ico" type="image/x-ico" />
    <title><g:layoutTitle default="DAM"/></title>
    <g:layoutHead/>
</head>
<body>
<g:layoutBody/>
<div class="footer" role="contentinfo"></div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>

在默认main.gsp的底部是这样的:

<div id="spinner" class="spinner" style="display:none;">
    <g:message code="spinner.alt" default="Loading&hellip;"/>
</div>

<asset:javascript src="application.js"/>

问题是,我应该包括这些吗?在我使用grails的所有年份中,我从未见过UI中出现过微调器,所以我不确定这是否真的有效?

我猜我不想要application.js?

也不确定这是什么,因为它没有内容:

<div class="footer" role="contentinfo"></div>
grails bootstrap-4 grails-3.0 grails3 grails-3.3
1个回答
1
投票

问题是,我应该包括这些吗?

仅当您想要显示微调器时。默认的main.css定义了微调器的样式:

.spinner {
    background: url(../images/spinner.gif) 50% 50% no-repeat transparent;
    height: 16px;
    width: 16px;
    padding: 0.5em;
    position: absolute;
    right: 0;
    top: 0;
    text-indent: -9999px;
}

调整,但你觉得合适。

默认的sitemesh布局包含具有该样式的div,并且display设置为none,因此不会显示。

<div id="spinner" class="spinner" style="display:none;">
    <g:message code="spinner.alt" default="Loading&hellip;"/>
</div>

这种情况的一个典型用法是,如果你有一些Javascript做了一个动作,你想要在动作发生时显示微调器,Javascript可以设置display属性,这将导致微调器显示,直到设置该属性回到none

在我使用grails的所有年份中,我从未见过UI中出现过微调器,所以我不确定这是否真的有效?

它除非你做了一些可能会干扰它的改变。

我猜我不想要application.js?

很难说你是否想要这个。这真的取决于你的应用程序在做什么。 3.3.9应用程序的默认application.js拉入其他几个.js文件...

// This is a manifest file that'll be compiled into application.js.
//
// Any JavaScript file within this directory can be referenced here using a relative path.
//
// You're free to add application-wide JavaScript to this file, but it's generally better
// to create separate JavaScript files as needed.
//
//= require jquery-3.3.1.min
//= require bootstrap
//= require popper.min
//= require_self

如果你不想让那些人进去,你可能不想要application.js。当然,您可以编辑application.js以包含您想要引入的任何内容。

也不确定这是什么,因为它没有内容:

<div class="footer" role="contentinfo"></div>

该元素作为占位符,您可以呈现常见的页脚元素。

© www.soinside.com 2019 - 2024. All rights reserved.