html页面调用js方法时的两种传参方式

<tbody th:if="${pageInfo?.list}">
<tr th:each="groupList,loopStatus : ${pageInfo?.list}">
<td id='number0' th:if="${flag}==0" th:each="group,loopStatus : ${groupList}" >
<label th:text="${group?.phoneNo}"></label>
<a id='edit0' href="javaScript:void(0);"
th:data-phoneId="${group?.Id}"
th:data-dataUserId="${group?.dataUserId}"
th:onclick="groupAdd.showModify([[${group.phoneNo}]],this.getAttribute('data-phoneId'),this.getAttribute('data-dataUserId'))">
编辑
</a>
<a id='delete0' href="javaScript:void(0);"
th:data-phoneId="${group?.Id}"
th:data-dataUserId="${group?.dataUserId}"
th:onclick="groupAdd.deletePhone([[${group.phoneNo}]],this.getAttribute('data-phoneId'),this.getAttribute('data-dataUserId'))">
删除
</a>
</td>
  </tr>
</tbody>

1.有th标签时,可以用this.getAttribute('data-phoneId')方式,其中data-phoneId为页面经过th定义的参数;
2.不用th标签时,可以用[[${group.phoneNo}]]方式,通过双重中括号,直接获取group对象里的phoneNo.


猜你喜欢

转载自www.cnblogs.com/xuhk1819/p/12189138.html