我想制作一个测验网络应用程序,每当我在其中添加地图功能时QuestionBox.js都会出错。
有没有人有这个问题的解决方案?
错误 :
4 | const [answer, setAnswer] = useState(options);
5 | return (
6 | <div className="questionBox">
> 7 | <div className="question">{question}</div>
| ^ 8 | {answer.map((text, index) => (
9 | <button
10 | key={index}
代码QuestionBox.js:
import React, {useState} from "react";
const QuestionBox = ({question, options, selected}) => {
const [answer, setAnswer] = useState(options);
return (
<div className="questionBox">
<div className="question">{question}</div>
{answer.map((text, index) => (
<button
key={index}
className="answerBtn"
onClick={() => {
setAnswer([text]);
selected(text);
}}
>
{text}
</button>
))}
</div>
);
};
export default QuestionBox;
郎朗坤
红糖糍粑
慕容3067478
相关分类