<FlatList
data={this.state.stuList}
renderItem={this._renderItem}
keyExtractor={this._keExtractor}
ItemSeparatorComponent={this_reparator}
ListHeaderComponent={this._header}
onRefresh={this._onRefresh} //下拉刷新头部事件
refreshing={this.state.refreshing}
/>
this.state={refreshing:false,
stuList:[]};
_renderItem=({item})=>{
return (<View>{item.Xxxx}</View>);
}
_keyExtractor=(item,index)=>{
return item.id.toString();
}
_separator=()=>{
return <View/>
}
_header=()=>{
return <View/>
}
_onRefresh=()=>{
fetch()....
}
-------------------------------------------
前后端连接
fetch(
" ",
{
method:"post",
mode:'cors',
headers:{
Accept:"application/json",
"Content-Type":"application/json"
},
body:JSON.stringify({username:"DeepL"})
}
).then(response=>respone.json())
.then(myjson=>{
this.setState({
ageEvent:china.name;
})
}).cathc(err=>{
alert(err);
})