【发布时间】:2021-08-05 11:49:15
【问题描述】:
当我使用属性th:attr 时,一切正常。
但是当我想在没有th:attr 的情况下使用th:onclick 时,出现错误。
在没有th:attr 的情况下,我需要做什么才能使其正常运行?
<button th:each="user : ${users}"
th:if="(${user.id} == ${user.id})"
th:attr="onclick='changeUser(\''+ ${user.id} + '\', \''+ ${user.name} + '\');'">click on me</button>
【问题讨论】:
-
请注意,使用链接答案中的方法后,您将不再需要使用
th:onclick。您可以使用onclick。