function updateFAQ(e, id) {
let newFAQList = [...faqDesc];
console.log(e.target.value);
newFAQList[id].question = e.target.value;
//newFAQList[id].answer = e.target.value;
setfaq(newFAQList);
}
function EditFAQ(props) {
return (
<form>
<TextField
name="question"
onChange={e => props.onChange(e, props.id)}
value={props.question}
></TextField>
<Divider />
<TextField
name="answer"
value={props.answer}
onChange={e => props.onChange(e, props.id)}
></TextField>
<button> Save Edit </button>
</form>
);
}
{
"id": 4,
"question": "question",
"answer": "answer"
},
进入
{
"id": 4,
"question": "changed question",
"answer": "answer changed"
},
如何在给定索引处更新问答的常见问题解答?我计划有一个表格来更新给定索引处的常见问题解答列表。我想更新类似示例的内容,但我尝试使用 e.target.name 来获取该字段并将其放在 newFAQList[id].e.target.name= e.target.value 旁边但不起作用
qq_笑_17
四季花海
相关分类