我将学者设置为数组列表。
const handleChange=(idx:any)=>(event:any)=>{
const target = event.target;
const value = target.value;
var name = target.name;
const academics = [...state.academics];
academics[idx]= {
[name]: value
};
setState({
academics
});
};
这是我在无法设置状态的输入字段中进行输入更改。
<div>
<table
id="tab_logic"
>
<thead>
<tr>
<th>#</th>
<th> Qualification </th>
<th> Institude </th>
<th> Percentage </th>
<th>YearOfPassing </th>
</tr>
</thead>
<tbody>
{state.academics.map((item, idx) => (
<tr id="addr0" key={idx}>
<td>{idx}</td>
<td>
<IonInput
type="text"
id="quali"
name={"qualification"}
value={state.academics[idx].qualification}
className="ioninput"
onIonChange ={handleChange(idx)}
/>
</td>
<td>
<IonInput
type="text"
name="institude"
id="inst"
value={state.academics[idx].institude}
className="ioninput"
onIonChange={handleChange(idx)}
/></td>
<td>
<IonInput
type="text"
name="percentage"
id="per"
value={state.academics[idx].percentage}
className="ioninput"
onIonChange={handleChange(idx)}
/></td>
<td>
<IonInput
type="text"
name="yearOfPassing"
id="year"
value={state.academics[idx].yearOfPassing}
className="ioninput"
onIonChange={handleChange(idx)}
/>
</td>
<td>
enter image description here我已经将输入字段设置为像资格,学历,百分比,通过年等行。当我输入资格时需要花的时间,而我要进入学院时,该资格未在字段中设置。