用thymeleaf在html标签中调用函数

时间:2017-12-08 15:36:12

标签: javascript html thymeleaf

如何在功能中正确传递${policies.getId(),同时循环播放${policies}

    <html>
        ... 
        <table>
            <thead>
              <tr>
                <th>id</th>
                <th>name</th>
              </tr>
            </thead>
            <tbody>
                <tr  th:each="policies : ${policies}" >
                  <td th:object="${policies.getId()}" onload="myFunction01(object)"></td>
                  <td th:object="${policies.getName()}" onload="myFunction02(object)"></td>
                </tr>
            </tbody>
          </table>

    <script th:inline="javascript">
    function myFunction01(object){...} 
    function myFunction02(object){...} 
     </script>  
</html>

1 个答案:

答案 0 :(得分:0)

你可以尝试一下,让我知道这是否适合你

th:onload ="'myFunction01(\'' + ${policies.getId()} + '\');'"