循环每个'repo'的正确方法是什么?
...
render(){
const watchers = [];
const names = [];
this.props.repos.map(repo => (
names.push(repo.name)
watchers.push(repo.watchers)
));
return(...)
}
答案 0 :(得分:1)
我认为实现这一目标的最简单方法是
...
render(){
const watchers = this.props.repos.map(r => r.watchers);
const names = this.props.repos.map(r => name);
return(...)
}