javascript - 表单中带有模板文字的 EJS
问题描述
我需要在表单内的 action 道具中插入一个带有模板文字的 id。
例子:
<div>
<h6>Cookmaster - Receitas</h6>
// Similar Template, but i need a EJS template
<form action={`/recipes/${id}`} method="POST">
<label for="title">Título da Receita</label>
<input type="text" id="title" name="title" value=<%= title %>>
<br>
<label for="ingredients">Ingredientes</label>
<textarea type="text" id="ingredients" name="ingredients" value=<%= ingredients %>></textarea>
<br>
<label for="detailsRecipe">Modo de Preparo</label>
<textarea type="text" id="detailsRecipe" name="detailsRecipe" value=<%= detailsRecipe %>></textarea>
<br>
<button type="submit">Enviar Receita</button>
</form>
</div>
但我不知道如何在这种情况下插入模板文字。
感谢帮助。
解决方案
经过多次尝试,有:
<form action=<%= `/recipes/${id}` %> method="POST">
tks。
推荐阅读
- java - optionsmenu onOptionsItemSelected 不会触发
- javascript - 当多次设置运行它的变量而不使用计时器时,如何每次调用 ngFor?
- javascript - 在 Ag Grid 中禁用多列过滤器
- mysql - 更改大型数据库的 MySQL 排序规则
- flutter - 为什么中心小部件不适用于颤动中的行和列
- c++ - 使用 MinGW-64 构建 Qt 5.15.2:构建错误(缺少 EGL/egl.h)
- c# - 使用 EF Core 中的方法进行查询?
- javascript - 获取时无法修复错误 - React.js
- uml - 如何建模从同一类调用操作的 UML 活动?
- ocaml - 当记录类型具有相同标签时修复类型推断