我正在使用百里香叶框架。如果值显示为空,我想隐藏整个 div。并显示它是否不为空。
html代码
<div>
<h2> My Table </h2>
<table border="1">
<tr bgcolor="powderblue">
<th>name</th>
<th>age</th>
<th>hobby</th>
<th>interest</th>
<th>books</th>
<th>movie</th>
</tr>
<tr th:each="table: ${myTable}">
<td th:text = "${table.name != null ? table.name : 'NULL'}" />
<td th:text = "${table.age != null ? table.age : 'NULL'}" />
<td th:text = "${table.hobby != null ? table.hobby : 'NULL'}" />
<td th:text = "${table.interest != null ? table.interest: 'NULL'}" />
<td th:text = "${table.books != null ? table.books : 'NULL'}" />
<td th:text = "${table.movie != null ? table.movie : 'NULL'}" />
</tr>
</table>
</div>
当 "tr th:each="table: ${myTable}" 没有显示任何值时,如何隐藏这个 div?它不必是严格的 thymeleaf 函数。如果可能,我可以使用 angularjs 函数。
困惑
我正在考虑做一些事情,如果 tr 标签为空隐藏 div。但是我的第一个 tr 标签不会为空,因为它是静态的。
输出
My Table
|name | age | hobby | interest | books | movies |
| | | | | | |
如果值为空/空,如何隐藏整体?表值因数据库而异并获得。有时可以为空有时有值
如果您使用 Thymeleaf 3.xx 版,它将帮助您:
<div th:if="${!myTable.isEmpty()}">
...
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句