【发布时间】:2018-09-22 11:00:41
【问题描述】:
我正在尝试从我所在州的数据中生成一个:
const { id } = this.props.match.params;
const formGen = this.state.arr.map(arr => {
if (id == arr.id) {
const inner = this.state.arr.input.map(inputs => (
<div>
<h1>{arr.name}</h1>
<label>{inputs.inputLabel}</label>
<input value={inputs.inputValue} type={inputs.inputType} />
</div>
));
}
});
现在,我不知道如何让它显示在渲染选项卡中,因为我在变量中有一个变量:
<form />
{formGen.inner}
</div>
这是我正在尝试映射的状态
arr: [
{
id: 1,
name: 'firstForm',
input: [
{
inputLabel: 'wowLabel',
inputType: 'wowType',
inputValue: 'wowValue'
},
{
inputLabel: 'wowLabel2',
inputType: 'wowType2',
inputValue: 'wowValue2'
}
]
}
【问题讨论】:
-
为什么不把 {formGen.inner} 放在表单中?