import React, { Component } from “react”;
import {
Platform,
StyleSheet,
Text,
View,
FlatList,
Image
} from “react-native”;
export default class Jiexi extends Component {
constructor(props) {
super(props);
this.state = {
arr: []
};
}
componentDidMount() {
fetch(
“http://api.shujuzhihui.cn/api/news/list?appKey=3e50f800ce7f4cdd9eda8d1c1ca71792&category=娱乐”
)
.then(response => response.json())
.then(responseJson => {
this.setState({ arr: responseJson.RESULT.newsList });
})
.catch(error => {
console.warn(error);
});
}
render() {
return (
<FlatList
data={this.state.arr}
renderItem={({ item }) => (
<Image
style={{ width: 50, height: 50 }}
source={{ uri: “http:” + item.newsImg }}
/>
)}
/>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: “center”,
alignItems: “center”,
backgroundColor: “#F5FCFF”
}
});