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

React this.state.names.map is not a function

React this.state.names.map is not a function

月关宝盒 2018-08-10 10:10:10
1: 遍历数据出错const Dashboard = React.createClass({    getInitialState:function(){        return{            names:[]        }    },    componentDidMount:function(){            var test={            "list": [                {                    "id": 1                },                {                    "id": 7                },            ]        }        this.setState({names:test})    },    render() {        return (                <div>                    {                        this.state.names.map(function (list) {                            return <div>Hello, {list.id}!</div>                        })                    }                                   </div>            )    }})数据取不到,this.state.names.map is not a function报这个错 是数据类型有问题么,没找出具体问题?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 6975 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信