前段時間項目中常常遇到一些a標籤的onclick時間的傳參問題javascript
提示些 is not defined 問題:html
源碼以下: java
<td>${login}</td> <td><span class="zh">${name_zh}</span></td> <td><span class="en">${name_en}</span></td> <td>${email}</td> <td>${phone}</td> <td>${created_at}</td> <td>${updated_at}</td> <td>${admin_note}</td> <td> <div class="btn-group"> <a href="showUsers.action?id=${id}" class="btn btn-default"> <span class="glyphicon glyphicon-eye-open"></span>view </a> <a href="editUsers.action?id=${id}" class="btn btn-primary"> <span class="glyphicon glyphicon-edit"></span> Edit</a> <a href="destroyUsers.action?id=${id}" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> Del</a> <a href="javascript:void(0);" onclick="unbindPhone(${id },${login },${phone })" class="btn btn-warning"><span class="glyphicon glyphicon-plane"></span>unbind</a> </div> </td>
這是由於 在 spa
onclick="unbindPhone(${id },${login },${phone })"
代碼中 JSP將${login }等參數當成了變量,因此會報沒有undefined的錯誤code
加上單引號就OK了htm
onclick="unbindPhone('${id }','${login }','${phone }')"