Html Thymeleaf:是否有类似于th:classappend的方法来删除类值?
我试图在某个屏幕上用以下代码显示一个警报:Html Thymeleaf:是否有类似于th:classappend的方法来删除类值?,html,thymeleaf,Html,Thymeleaf,我试图在某个屏幕上用以下代码显示一个警报: <div id="errorDiv" class="alert alert-danger hidden"> <label id="errorLabel"></label> <button type="button" class="close" data-hide="alert" aria-hidden="true">×</button> </div&g
<div id="errorDiv" class="alert alert-danger hidden">
<label id="errorLabel"></label>
<button type="button" class="close" data-hide="alert" aria-hidden="true">×</button>
</div>
&时代;
默认情况下,errorDiv是隐藏的,因为它的值隐藏在class属性中(我使用的是引导)
我希望在类似的内容中找到类似的内容,但不是添加值,而是删除class属性中的“隐藏”值以显示div。我认为您可以使用条件css class include withelvis操作符,类似于:
<div id="errorDiv" class="alert alert-danger" th:classappend="*{isError}?:'hidden'">
<label id="errorLabel"></label>
<button type="button" class="close" data-hide="alert" aria-hidden="true">×</button>
</div>
&时代;
仅当*{isError}
为null
时,才应将'hidden'
附加到class属性
见谢谢。我必须在你的表达式中添加字符:它可以工作,因为如果
*{isError}:“hidden”
@AndrésCuadrosSuárez,我想应该是th:classappend=“not*{isError}?”hidden'
,因为使用?:
如果*{isError},则isError
的值将被追加到类中
计算结果为true
。