【发布时间】:2017-09-20 04:37:36
【问题描述】:
【问题讨论】:
标签: admin-on-rest
【问题讨论】:
标签: admin-on-rest
输入组件使用 Redux-Form 来实际渲染表单并将应用程序状态连接到输入组件。
输入道具在幕后由 ReferenceInput 传递给它的孩子。
如果您想创建孩子,那么您需要执行以下操作。这是来自我的应用程序的代码,但我相信您会看到这种模式。
const TaleGenreInput = ({style, text, ...props}) => {
return (
<div style={style.container} >
<span style={style.span}>{text}: </span>
<ReferenceInput {...props} reference="genres" >
<GenreInputGroup {...props} style={style} elStyle={style.elStyle} optionText='name' />
</ReferenceInput>
</div>
)
}
const GenreInputGroup = ({style, elStyle, optionText, ...rest}) => {
return (
<div>
<SelectInput {...rest} style={style.dropdown} elStyle={style.dropDownElStyle} optionText='name' allowEmpty />
<SelectInput {...rest} style={style.dropdown} elStyle={style.dropDownElStyle} optionText='name' allowEmpty />
</div>
)
}
{...rest} 确保从父级传递的所有道具都进入 SelectInput。您还可以控制台记录其值以查看它包含的所有内容。对调试有很大帮助。
【讨论】: