JSONを使用して動的にフィールドを作成する必要があります。 必要に応じてコンポーネントを作成しました。ページには必須フィールドが表示されます。 しかし、InputField jsファイルにonchange関数があっても、フィールドは編集不可能な状態です。以下は私のコンポーネントのコードの一部ですReactJSフィールドは動的フィールドに対して編集できません
onChange(event) {
this.setState({
[event.target.name]: event.target.value
})
}
render() {
return (
this.props.screenField.fieldType === 'INPUT'
? <div className='form-group'>
<label htmlFor={this.props.screenField.name}>{this.props.screenField.label}:</label>
<input type={this.props.screenField.dataType === 'BOOLEAN'
? 'checkbox'
: this.props.screenField.dataType}
name={this.props.screenField.name}
id={this.props.screenField.name}
placeholder={this.props.screenField.helpText}
required={this.props.screenField.isRequired}
value={this.props.screenField.value} className='form-control'
onChange={this.onChange.bind(this)}/>
</div>
: null
)
}
コード全体の下のURLを見つけてください。
https://github.com/yvsivateja/ReactJSApplications/tree/one/React-json-render
質問は何ですか? – nbkhope