0
ページのローディング<フォーム/>
<Form data={
[
{
element: 'input',
type: 'text',
placeholder: 'Jamie is Sex'
},
{
element: 'input',
type: 'text',
placeholder: 'Jamie is Not Sex'
},
{
element: 'input',
type: 'password',
placeholder: 'Jamie is Not Sex'
}
]
}/>
<フォーム/>/form.js
var buildElements = this.props.data.map(function (item) {
var element = import item['type'] from './'+item['type'];
return element;
});
私はif文を行うことが実現するが、私はそれを頼りにしたいですファイルシステム上で。ファイルがノードに存在するかどうかを確認する必要があるかもしれません。
いいえ、これはES2015では不可能です:http://stackoverflow.com/questions/30340005/importing-modules-using-es6-syntax-and-dynamic-path CommonJSの構文でwebpackまたはbrowserifyを見てください代わりに。 – nils