问候!
我有一个常规的function
,我正在返回一个span
(prop
如果我没记错的话)。在我的 ts 代码上我有这个错误
这是我的代码。文件名是qCard.tsx
import { QuestionAnswerTwoTone } from "@material-ui/icons";
import React from "react";
// crear props
type Props = {
question: string;
answers: string[];
callback: any;
userAnswer: boolean;
questionNm: number;
totalQuestions: number;
};
// A function statement declared component that takes no children.
export default function QuestionCard({
question,
answers,
callback,
userAnswer,
questionNm,
totalQuestions,
}: Props) {
//duda
return (<div>
<p> Question : {questionNm} / {totalQuestions} </p>
<p dangerouslySetInnerHTML={{ __html: question }} />
<div>
{answers.map(function answer(){
return( <div>
<button disabled={userAnswer} onClick={callback}>
<span dangerouslySetInnerHTML={{ __html: answer }}/>
</button>
</div>);
} )}
</div>
</div>
);
}
(错误线)
我试图删除{{ **__html**: answer }}
它,就像 :{{ answer }}
但它不起作用。