thymeleaf+bootstrap,onclick传参实现模态框中遇到的错误

原文链接:thymeleaf+bootstrap,onclick传参实现模态框中遇到的错误

 

<button class="btn btn-xs btn-danger" th:data-name="${promoter?.number}" onclick="checkBanl(this.getAttribute('data-name'))" type="button" style="margin: 1px;!important;">
<i class="ace-icon fa bigger-120">封禁该账号及其所有下级</i>
</button>

 

onclick调javascript函数时,不能直接使用onclick=“editUser(${prod.id})”,这样会报错,需要修改成如下的格式。

<a id="myModal" data-toggle="modal" data-target="#exampleModal" th:οnclick="'javascript:Values('+${item.id}+')'">评价服务</a>

 

但是这种方式对于我的问题并不是很适用,按照这种方式,改过之后,前端依旧报错

取不到传递的字符串,大概就是这个被传递的字符串木有被定义 is not define

 

所以,对于thymeleaf+bootstrap,onclick传递字符串参数时,应该是酱婶儿的

<a href="#editModal" role="button" data-toggle="modal" th:onclick="'javascript:editUser(\''+${prod.id}+'\');'">修改</a>

posted @ 2020-01-06 12:54  萌胖胖  阅读(543)  评论(0)    收藏  举报