我从开源api中获得了数据,并且试图从列表中一一获得数据。但是,当我显示来自渲染零件的数据时,它以字符串类型显示,如下例所示。我的问题是我应该将其更改为对象并使其成为列表,然后逐个获取数据吗?还是我的代码做错了什么。我的代码太多了
dataartistListid5137nameCheat CodesticketLinkhttps://edmtrain.com/new-jersey?event = 110880&ticketsfestivalIndnamedate2019-05-25venueid3250nameBorgata PremierlocationAtlantic City,NJaddress1 Borgata Way,Atlantic City,NJ 08401,USAstateNew Jerseylatitude39.378longitudeD-15:20-03:03:74ate:30-03:07:30:43:55:00:00:00:00:00:00:03-03:23:03:00:00:00:03:00:00:00:00:00-03-03:23-03 05Zlinkhttps://edmtrain.com/new-jersey?event = 110880id110880artistListid375nameLaidback LuketicketLinkhttps://edmtrain.com/new-jersey?event = 111099&ticketsfestivalIndnamedate2019-05-25venueid5414nameHQ2 NightclublocationAtlantic City,NJaddress500 Boardwalk,Atlantic City,Newstate 39long,纽约州新泽西州拉特兰特,363 -74.414ages21 + createdDate2019-03-22T19:56:21Zlinkhttps://edmtrain.com/new-jersey?event = 111099id111099artistListid83nameArmin Van BuurenticketLinkhttps://edmtrain.com/new-jersey?event = 111373&ticketsfestivalIndnamedate2019-05-25venueid5415nameHQ2 Beachclub NJaddress500木板路,大西洋城,NJ 08401,美国州新泽西州纬度39.363纵向e-
// reducer
export default handleActions({
...pender({
type: GET_POST_LIST,
onSuccess: (state, action) => {
const { data: posts } = action.payload;
const lastPage = action.payload.headers['last-page'];
return state.set('posts', fromJS(posts));
}
})
}, initialState)
//Container
render() {
const { loading, posts, city, state } = this.props;
if(loading) return null; // Do not show anything while loading
return (
<div>
<PostList posts={posts}/>
</div>
);
}
}
export default connect(
(state) => ({
//lastPage: state.list.get('lastPage'),
posts: state.list.get('posts'),
loading: state.pender.pending['list/GET_POST_LIST']
}),
(dispatch) => ({
ListActions: bindActionCreators(listActions, dispatch)
})
)(ListContainer);
```
//PostList component
const PostList = ({posts}) => {
const postList = posts;
return (
<div>
{postList}
</div>
);
};
export default PostList;
答案 0 :(得分:0)
我意识到我使用了fromJS,它从reducer变成了数组。拿走那部分,我得到了对象类型的数据。