我有一個需求,其中我需要通過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
)
}
請在下面的示例中查找完整的代碼。
https://github.com/yvsivateja/ReactJSApplications/tree/one/React-json-render
那麼問題是什麼? – nbkhope