如果在标签“ Tipo consenso”中我选择了“ Leggi Referto”选项,那么我想显示“ Codice Referto”字段,否则,我不想显示它。
Form onSubmit={this.handleSubmit}>
<div className="form-section">
<Label for="type" text="Tipo consenso" />
<select
name="rights"
value={this.state.rights}
onChange={this.handleInputChange}>
<option default value="vuoto"></option>
<option value="Carica Referto">Carica Referto</option>
<option value="Leggi Referto">Leggi Referto</option>
</select>
<Label text="Codice Referto" />
<input
onVisible={this.checkVisibility}
type="text"
name="codiceReferto"
placeholder="Inserire hash referto"
autoFocus
onKeyPress={this.onEnter} //allows you to move to the next panel with the enter key
value={this.state.codiceReferto}
onChange={this.handleInputChange}
/>
最佳答案
请尝试以下代码,希望对您有所帮助
{
this.state.rights === 'Leggi Referto' ?
<div>
<Label text="Codice Referto" />
<input
onVisible={this.checkVisibility}
type="text"
name="codiceReferto"
placeholder="Inserire hash referto"
autoFocus
onKeyPress={this.onEnter} //allows you to move to the next panel with the enter key
value={this.state.codiceReferto}
onChange={this.handleInputChange}
/>
</div> : null
}