如何在撇号内插入 EJS 标签?
How to insert EJS tag inside of apostrophes?
我正在尝试通过单击具有 onClick=location.href
属性的按钮向特定端点发出 GET 请求。
但是我不知道如何让 EJS 标签在撇号内工作。
<button type="button" onclick='location.href="/<%= todoList.title %>"'>delete</button>
我想得到这个结果:
<button type="button" onclick="location.href="/football">delete</button>
虽然我得到了,
<button type="button" onclick="location.href="/">delete</button>
尝试
<button type="button" onclick='location.href="/<%- todoList.title %>"'>delete</button>
在 JS 中使用 <%- %>
而不是 <%= %>
(onclick 函数)
或
使用link是否使用带onclick功能的按钮
<a href="/<%= todoList.title %>">delete</a>
// if you use bootstrap as framework
<a href="/<%= todoList.title %>" class="btn">delete</a>
我正在尝试通过单击具有 onClick=location.href
属性的按钮向特定端点发出 GET 请求。
但是我不知道如何让 EJS 标签在撇号内工作。
<button type="button" onclick='location.href="/<%= todoList.title %>"'>delete</button>
我想得到这个结果:
<button type="button" onclick="location.href="/football">delete</button>
虽然我得到了,
<button type="button" onclick="location.href="/">delete</button>
尝试
<button type="button" onclick='location.href="/<%- todoList.title %>"'>delete</button>
在 JS 中使用 <%- %>
而不是 <%= %>
(onclick 函数)
或
使用link是否使用带onclick功能的按钮
<a href="/<%= todoList.title %>">delete</a>
// if you use bootstrap as framework
<a href="/<%= todoList.title %>" class="btn">delete</a>