如何获取 api 获取结果并在卡片中查看结果?
How to get the api fetch result and view the result inside a card in react native?
Profile.js
fetch('http://test.wehubs.in/MobileApp/profile.php',{
method: 'POST' ,
headers:{
'Accept': 'application/json'
},
body: JSON.stringify({
uuid: value
})
}).then(response =>response.json())
.then((responseData) =>
{
});
我想通过从 db.Also 中获取内容来显示用户个人资料详细信息我想在卡片中显示此结果?这怎么可能?
const Profile = (props)=>{
return(
<Card>
<CardImage
source={require('')} style={styles.imagestyle} />
<CardTitle title="Name" />
<CardContent text="Location bloodgroup"/>
<CardButton
onPress={() => {}}
title="Back"
color='red'
/>
</Card>
);
}
以上是我在 card.I 中显示详细信息的代码,想显示 CardTitle
处的提取响应中的用户名。请帮助 me.Don 不知道如何执行此操作。
获取代码应该放在 componentDidMount 中。它应该更新组件的状态。
.then((responseData) => {
this.setState({ user: responseData });
});
CardTitle 应该显示状态。
<CardTitle title={this.state.user && this.state.user.name} />
我已经像这样编辑了获取响应
}).then(response =>response.json())
.then((responseData) =>
{
this.setState({
user: (responseData.name),
usernew: (responseData.bloodgroup),
loaded:true,
})
然后我就能够在卡片中访问此响应。
<CardTitle style={styles.containerStyle} title={this.state.user} />
Profile.js
fetch('http://test.wehubs.in/MobileApp/profile.php',{
method: 'POST' ,
headers:{
'Accept': 'application/json'
},
body: JSON.stringify({
uuid: value
})
}).then(response =>response.json())
.then((responseData) =>
{
});
我想通过从 db.Also 中获取内容来显示用户个人资料详细信息我想在卡片中显示此结果?这怎么可能?
const Profile = (props)=>{
return(
<Card>
<CardImage
source={require('')} style={styles.imagestyle} />
<CardTitle title="Name" />
<CardContent text="Location bloodgroup"/>
<CardButton
onPress={() => {}}
title="Back"
color='red'
/>
</Card>
);
}
以上是我在 card.I 中显示详细信息的代码,想显示 CardTitle
处的提取响应中的用户名。请帮助 me.Don 不知道如何执行此操作。
获取代码应该放在 componentDidMount 中。它应该更新组件的状态。
.then((responseData) => {
this.setState({ user: responseData });
});
CardTitle 应该显示状态。
<CardTitle title={this.state.user && this.state.user.name} />
我已经像这样编辑了获取响应
}).then(response =>response.json())
.then((responseData) =>
{
this.setState({
user: (responseData.name),
usernew: (responseData.bloodgroup),
loaded:true,
})
然后我就能够在卡片中访问此响应。
<CardTitle style={styles.containerStyle} title={this.state.user} />