我得到一个属性html“image_clickable_status”,如果它是true,我需要使图像可点击,如果它是false,则图像不应该是可点击的。以下是我正在尝试做的事情
<div th:switch=${image_clickable_status}>
<a th:case=“true ” th:href="@{/getConsent/yes}">
<a th:case=“false ” th:href=“#”>
<img
src="https://samplegoogle.img" alt="viu"/>
</a>
</a>
</div>
但这不起作用,有什么想法可以更好地处理这种情况。
最佳答案
您可以使用pointer-events: none;
。
例如
<a th:style="${image_clickable_status} ? '' : 'pointer-events: none;'"
th:href="@{/getConsent/yes}">
<img src="https://samplegoogle.img" alt="viu"/>
</a>
关于java - 在 Thymeleaf 中根据特定条件使图像可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51942710/