记忆角落

  • {{ item.name }}
  • 首页
  • 关于
  • 归档
  • 邻居
  • 捐赠

thymeleaf使用th:onclick()遇到的一点小坑

  • 郭良俊只狗
  • 2019-03-18
  • 11

因为最近都一直没有用thymeleaf,于是温习了一下,但还是th:onclick()传参直接报错。

于是乎csdn普遍都是在调用之前添加javascript申明?

<button class="btn" th:onclick="'javascript:functionName(\''+${xx.xx}+'\');'">(spring boot 1.3版本没问题)

但是spring boot 新版本(2.xx)也会出现报错

于是解决办法可以用thymeleaf中的内联[[]]解决:

<button class="btn" th:onclick="functionName([[${xx.xx}]]);"></button>

最后水一句:wp最新的编辑器就是一坨屎!!

内联介绍-->https://www.cnblogs.com/suncj/p/4031486.html

参考手册-->https://blog.csdn.net/zrk1000/article/details/72667478


© 2012 - 2023 记忆角落 网站统计
Theme by Wing
粤ICP备14056850号-1 又拍云CDN赞助