在我当前的 spring-boot 项目中,我对这段 html 代码有一个看法:
<button type="button" class="btn btn-primary" onclick="upload()" th:utext="#{modal.save}"></button>
在onclick
属性中,对upload()
函数的调用应该有一个参数,该参数存储在thymeleaf变量${gallery}中
.
谁能告诉我上面命令中的表达式怎么用?
我已经尝试过了:
th:onclick="upload(${gallery)"
th:attr="onclick=upload(${gallery)"
这些都不起作用。
最佳答案
thymeleaf 3.0.10 th:onclick thymeleaf 变量不起作用
这应该可行:
th:attr="onclick=|upload('${gallery}')|"
关于javascript - 在 onclick 属性中使用 thymeleaf 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32650536/