【发布时间】:2018-08-27 13:42:43
【问题描述】:
export default class FutureLaunches extends React.Component {
constructor(props) {
super(props);
this.state = {
isLoading: true,
dataSource: null
};
}
componentDidMount() {
return fetch("https://launchlibrary.net/1.4/launch")
.then(response => response.json())
.then(responseJson => {
this.setState({
isLoading: false,
dataSource: responseJson.launches
});
})
.catch(error => {
console.log(error);
});
}
render() {
if (this.state.isLoading) {
return (
<View style={styles.container}>
<ActivityIndicator />
</View>
);
} else {
let launches = this.state.dataSource.map((val, key) => {
return (
<View key={key}>
<Text style={styles.name}>{val.name}</Text>
<Text>{val.net}</Text>
<Text>{val.windowstart}</Text>
<Text>{val.windowend}</Text>
<Text>{val.count}</Text>
</View>
);
});
return (
<View style={styles.container}>
<ScrollView contentContainerStyle={styles.contentContainer}>
{launches}
</ScrollView>
</View>
);
}
}
}
});
json中的total高于count,count显示页面上数据集的数量。我怎样才能更改 json 上的计数,以便它可以允许来自 https://launchlibrary.net/1.4/launch 的所有数据集,在这种情况下,有 183 个数据集可用。
【问题讨论】:
-
根据doc 注意:响应中的总数是满足您的标准的启动总数,用于分页。您可以通过更改偏移量来获取下一页。
-
如何更改偏移量?
标签: javascript api react-native count fetch