当前位置: 代码迷 >> 综合 >> Thmeleaf如何给点击函数传递多个参数
  详细解决方案

Thmeleaf如何给点击函数传递多个参数

热度:104   发布时间:2023-09-29 19:34:36.0
<h2 th:data-title ="${dep.depId}"th:onclick="'doThing('+${dep.id}+','+${1}+',this)'"th:text="${dep.name}+'('+${dep.status}+')'">
</h2>
 window.getCommonGoal = function (id, num, e) {var title = $(e).attr("data-title");//其他业务}

 

说明:

1.dep是后台传到前端的实体对象

2.th:data-title自定义的属性

3.点击事件可以传递可变的实体属性、固定值、this对象

 

  相关解决方案