【发布时间】:2017-12-04 04:20:50
【问题描述】:
我有一个应该呈现地图内容的 Thymeleaf 模板。这是模板:
<div class="akuiteo list-group" data-th-each="akuiteo:${akuiteoMap.akuiteoMap}">
<div data-th-replace="akuiteo::akuiteoView(${akuiteo.value},${akuiteo.key})"></div>
</div>
在 akuiteoView 我有:
<button data-th-fragment="akuiteoView(commits,akuiteoNr)" class="akuiteo-file" data-th-each="commit:${commits}" data-th-id="${akuiteoNr}">
<p data-th-text="${akuiteoNr}"></p>
<div data-th-replace="commitDetails::commitView(${commit})">replace me</div>
</button>
我得到的输出是:
<body>
<div class="akuiteo list-group">
<button> content </button>
</div>
<div class="akuiteo list-group">
<button> content </button>
<button> content </button>
<button> content </button>
<button> content </button>
<button> content </button>
<button> content </button>
</div>
</body>
akuiteo 类的 div 重复了,而且每次提交都有一个按钮,而不是每个 akuiteo 实例有一个按钮,我不明白为什么会发生这种情况,预期的输出是:
<body>
<div class="akuiteo list-group">
<button> content(a list of one commit) </button>
<button> content(a list of 6 commits) </button>
</div>
</body>
【问题讨论】:
-
在我发布答案之前,您能告诉我为什么要使用
<button>元素来呈现内容吗?你不应该在按钮中嵌套像<div>和<p>这样的标签,因为它在语法上不正确,所以你的按钮应该替换为div。 -
我这样做是因为它有一个引导功能,可以使用按钮启用多选列表,尽管有可能避免这种情况