th:with 和 th:if 在百里香叶中有什么区别?我使用 th:if 还是 th:with?我不太确定他们的区别。
我试图搜索 th:with 的用法,但周围没有太多文档。
例如,
<td>
<div th:with="${a given condition}"> <!--do I use th:if or th:with here?-->
<span th:if="${}"></span>
<span th:if="${}"></span>
</div>
</td>
th:with
用于分配变量。它与评估条件无关,而是用于为变量赋值。sytnax 看起来像这样:
<div th:with="firstPer=${persons[0]}">
th:if
和th:unless
用于评估条件(以确定是否显示一个 html 块)。
<div th:if="${user.isAdmin()} == false">
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句