fix: 添加选项数据的防御性检查
- 在ExamOnline和ExamPrint中对question.options添加空值检查 - 使用 (question.options || []) 防止 undefined 错误 - 确保在选项数据缺失时不会导致页面崩溃 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
a62c5b3e62
commit
536b7f23c6
@ -288,7 +288,7 @@ const ExamOnline: React.FC = () => {
|
|||||||
>
|
>
|
||||||
<Radio.Group>
|
<Radio.Group>
|
||||||
<Space direction="vertical">
|
<Space direction="vertical">
|
||||||
{question.options.map((opt) => (
|
{(question.options || []).map((opt) => (
|
||||||
<Radio key={opt.key} value={opt.key}>
|
<Radio key={opt.key} value={opt.key}>
|
||||||
{opt.key}. {opt.value}
|
{opt.key}. {opt.value}
|
||||||
</Radio>
|
</Radio>
|
||||||
@ -315,7 +315,7 @@ const ExamOnline: React.FC = () => {
|
|||||||
>
|
>
|
||||||
<Checkbox.Group>
|
<Checkbox.Group>
|
||||||
<Space direction="vertical">
|
<Space direction="vertical">
|
||||||
{question.options.map((opt) => (
|
{(question.options || []).map((opt) => (
|
||||||
<Checkbox key={opt.key} value={opt.key}>
|
<Checkbox key={opt.key} value={opt.key}>
|
||||||
{opt.key}. {opt.value}
|
{opt.key}. {opt.value}
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
|
|||||||
@ -210,7 +210,7 @@ const ExamPrint: React.FC = () => {
|
|||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.optionsList}>
|
<div className={styles.optionsList}>
|
||||||
{question.options.map((opt) => (
|
{(question.options || []).map((opt) => (
|
||||||
<div key={opt.key} className={styles.optionItem}>
|
<div key={opt.key} className={styles.optionItem}>
|
||||||
{opt.key}. {opt.value}
|
{opt.key}. {opt.value}
|
||||||
</div>
|
</div>
|
||||||
@ -237,7 +237,7 @@ const ExamPrint: React.FC = () => {
|
|||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.optionsList}>
|
<div className={styles.optionsList}>
|
||||||
{question.options.map((opt) => (
|
{(question.options || []).map((opt) => (
|
||||||
<div key={opt.key} className={styles.optionItem}>
|
<div key={opt.key} className={styles.optionItem}>
|
||||||
{opt.key}. {opt.value}
|
{opt.key}. {opt.value}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user