为了账号安全,请及时绑定邮箱和手机立即绑定

类型错误:无法读取未定义的 Reactjs 的属性“地图”?

类型错误:无法读取未定义的 Reactjs 的属性“地图”?

qq_笑_17 2022-12-09 13:49:05
类型错误:无法读取未定义的 Reactjs 的属性“地图”?我正在使用小测验模块但显示以下错误请帮助我解决以下错误类型错误:无法读取未定义的属性“地图”我不知道如何解决我是新来的反应豌豆帮助我这个代码索引.jsimport React from 'react';import ReactDOM from 'react-dom';import './index.css';import App from './App';import Questionlist from './quiz/Questionlist.jsx';import * as serviceWorker from './serviceWorker';class Quiz extends React.Component {    constructor(props){        super(props);            this.state= {                questions : [                    {                        id: 1,                        text: 'What is your name?',                        choices:[                            {                                id: 'a',                                text: 'Michael'                            },                            {                                id: 'b',                                text: 'Brand'                            },                            {                                id: 'c',                                text: 'Steven'                            },                        ],                        correct: 'b'                    },                    {                        id: 2,                        text: 'What is your mother name?',                        choices:[                            {                                id: 'a',                                text: 'Sara'                            },                            {                                id: 'b',                                text: 'Denny'                            },                            {                                id: 'c',                                text: 'senny'                            },                        ],                        correct: 'c'                    },            
查看完整描述

2 回答

?
长风秋雁

TA贡献1757条经验 获得超7个赞

将您的数组传递给问题列表组件。

如果没有用,请尝试删除您的Garage组件,因为您在 Quiz 组件中有 array(questions)。将问题从 Quiz 组件传递到Questionlist组件。

代替

render() { 
   return <h2>I am a Car!</h2>;
    }

像这样通过

render() { 
   return <Questionlist questions={this.state.questions} />
    }

最后将根组件从Garage更改为Quiz

ReactDOM.render(<Quiz />, document.getElementById('root'));


查看完整回答
反对 回复 2022-12-09
?
莫回无

TA贡献1865条经验 获得超7个赞

要列出您没有传递的问题,它应该是:

 <Questionlist questions={this.state.questions} />


查看完整回答
反对 回复 2022-12-09
  • 2 回答
  • 0 关注
  • 112 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号