基础导航顶部栏不适用于thymelaf
Foundation navigation top-bar not working with thymeleaf
我有一个HTML模板文件,它使用Spring MVC+thymelaf,我正试图使用Foundation的"顶部栏"组件在页面顶部创建一个可导航菜单。
到目前为止,菜单栏已显示,但当光标位于顶部时,菜单不会显示。
我可以显示与主菜单选项相关的子菜单(位于栏上的子菜单),但子菜单不起作用,因为当我单击第一个子菜单上的某个选项时,菜单将关闭,而不是显示另一个子菜单。
我的HTML文件如下:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<link rel="stylesheet" type="text/css" media="all" th:href="@{/css/foundation.min.css}" />
</head>
<body>
<nav class="top-bar" role="navigation" data-topbar="true">
<ul class="title-area">
<li class="name">
</li>
<li class="toggle-topbar menu-icon"><a href="#"><span>Menu</span></a>
</li>
</ul>
<section class="top-bar-section">
<ul class="left">
<li class="divider"></li>
<li class="has-dropdown"><a href="#"><span th:text="#{menu.administration}"></span></a>
<ul class="dropdown">
<li class="has-dropdown"><a href="#"><span th:text="#{menu.administration.material}"></span></a>
<ul class="dropdown">
<li><a href="#"><span th:text="#{menu.administration.ontology}"></span></a></li>
</ul>
</li>
</ul>
</li>
</ul>
</section>
</nav>
<div>
<div class="large-12 columns">
<h2 th:text="#{material.search.title}"></h2>
</div>
</div>
<script th:href="@{/js/vendor/jquery.js}"></script>
<script th:href="@{/js/foundation.min.js}"></script>
<script th:href="@{/js/foundation/foundation.topbar.js}"></script>
<script th:href="@{/js/vendor/modernizr.js}"></script>
<script>
jQuery(document).ready({
jQuery(document).foundation();
});
</script>
</body>
</html>
我确信我的资源正在被正确地导入。
此外,我必须使用data-topbar="true"
,因为如果我只使用data-topbar
,我的页面在呈现时会失败,并在属性名称后显示=
。
我做错什么了吗?
非常感谢你们的帮助!
问题位于我用来导入JS文件的属性中。
正如在我的代码中看到的,导入看起来像这样:
<script th:href="@{/js/foundation.min.js}"></script>
但是要导入脚本文件,href
属性是错误的,它必须是src
,因此正确的格式是:
<script th:src="@{/js/foundation.min.js}"></script>
我知道这是一个愚蠢的错误,但我希望它能帮助其他人。
编译或生成页面时从未显示错误,这让我有点担心。
您的th:text="#{menu.administration}
不工作
结构应该是
<h1 th:text="${header.title}">title</h1>
<small th:text="${header.subtitle}">Subtitle</small>
你不能留下空的并期望一个值
请看一下教程http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html
相关文章:
- html5 drawImage适用于firefox,而不是chrome
- Jquery Ajax POST不工作.适用于GET
- 如何调试遗留的javascript代码(适用于IE,但在Google Chrome中不正常)
- .load()适用于window,而不是ID
- 使用Jquery更改css样式适用于id's、 不在课堂上
- 提交按钮不会;不适用于Chrome或Firefox,但适用于Internet Explorer
- 为什么 javascript 中的“btoa”编码适用于 20 位字符串而不是 20 位整数
- Javascript String to Date适用于Chrome,而不是FF或Safari
- Onchange,向上,向下箭头键适用于FF和Chrome,但在IE中不起作用
- .load() 适用于 IE 和 dreamweaver 预览版,但不能使用 opera 和 chrome
- 找不到适用于 Highcharts 的 JSON 数组语法
- 为什么在jQuery中使用focusout适用于Firefox,而使用addEventListener则不适用;t
- jQuery选择菜单验证器适用于FF和Chrome,但不适用IE
- 单选按钮'onclick'适用于Chrome和Firefox,但不适用IE
- JQuery ScrollTop适用于chrome,但不适用firefox
- window.opener.location.href适用于IE,但不适用Chrome或Safari
- Frame Busting buster不完全适用于IE
- Jquery touch punch适用于Chrome和Firefox,但不适用IE
- 背景更改仅适用于chrome+$.预加载不适用;不起作用
- JavaScript window.location.replace适用于Firefox,但不适用IE或Chrome