javascript - 帕格,如果表格中的语句不提取数据
问题描述
我正在尝试在 pug 中动态创建一个表单。
form(method='POST' action=postRoute)
each component in step.components
.row
if (component.pug == 'name')
input(type="text", name="title")
include component/name
else if (component.pug == 'description')
include component/description
else if (component.pug == 'thumbnail')
include component/imageLoader
else if (component.pug == 'tag_field')
include component/addTags
else if (component.pug == 'tag_equipment')
include component/addEquipmentTags
else if (component.pug == 'plans')
.add-plans-background-area
.row
a(href='#')
.add-plan(onclick='addNewPlan()') +
- for (var i = 0; i < 3; ++i)
.row.plan-preview-in-create(onclick='previewPlan()')
.col-md-1
img(src='https://www.healthline.com/hlcmsresource/images/bodybuilding-meal-plan-1296x728-feature.jpg').plan-thumbnail
.col-md-10
.plan-name= 'Package name ' + i
.col-md-1
.plan-exit
a(href='#' onclick='removePlanFromPackage()')
i.material-icons.menu-icon= 'close'
else
p= component.pug
.row.buttons-group
- if (index == 0)
.col-md-2
button(type="button" onclick=`nextInStepSectionDidClick('${stepIds}', '${index}')`).next-button-base.next-button-enable NEXT
- else if (index == (config.length - 1))
.col-md-2
button(type="button" onclick=`backInStepSectionDidClick('${stepIds}', '${index}')`).back-button-base BACK
.col-md-2
button.next-button-base.next-button(type='submit') SAVE
- else
.col-md-2
button(type="button" onclick=`backInStepSectionDidClick('${stepIds}', '${index}')`).back-button-base BACK
.col-md-2
button(type="button" onclick=`nextInStepSectionDidClick('${stepIds}', '${index}')`).next-button-base.next-button-enable NEXT
正如您所看到的,我有一个 for each 和一个配置文件,我正在动态创建表单。这将对我的项目有所帮助,因为我有很多相似的观点。
无论如何,当我提交表单时,我无法提取数据,但是当我在 if 语句上方添加一个输入时,我能够提取它。
// Get submited data
router.post('/', function (req, res) {
console.log(req.body);
res.send('Post page');
})
任何想法如何解决这个问题?
解决方案
推荐阅读
- swagger - Swagger Editor,如何添加额外的“隐藏”信息?
- sql - SQL Server 重置数字
- python - Matplotlib 更新时图形闪烁
- javascript - 在jspdf中为pdf创建矩阵类型卡片,与sap ui5集成
- scala - 如何使用 Scala Case Class 在 Spark Structured Streaming 中映射 Kafka 源
- onedrive - 如何从 OneDrive 取消链接工作帐户
- angular - 如何使用 ContentChildren 和 QueryList 重新排序孩子
- c# - 双击datagridview行后如何在dateTimePicker中获取正确的日期时间格式而不解析
- sql - 优化了 SQL SERVER 中逐字反转输入字符串的函数的替代代码
- java - 从 Json 手动映射到 crnk 中的 DTO 子类之一