3 回答

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超7個(gè)贊
我不知道這就是你要找的東西,但我會(huì)試一試:
代碼:
const renderText = () => {
// as soon as we received the data, we will display it
if (data.length > 0){
return (
<Text> name: {data[0].name} diploma: {data[1].education[0].diploma}</Text>
)
}
}
return (
<View>
{renderText()}
</View>
);
輸出:

TA貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超4個(gè)贊
由于您已經(jīng)將響應(yīng)保存在data數(shù)據(jù)中,因此應(yīng)該是這樣的,
data = [
{
code: "12459552",
id: 7,
name: "Dr xavier vilan",
speciality: "Cardio"
},
{
education: [
{
date_debut: "2020-02-07",
date_end: "2020-02-06",
diploma: "asmaa",
school: "asmaa",
city: "vullez"
}
]
}
]
現(xiàn)在您可以訪問(wèn)name&diploma如下,
name: data[0].name
diploma: data[1].education[0].diploma

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超4個(gè)贊
嘗試這個(gè):
return (
<View>{JSON.stringify(data, null, 2)}</View>
)
添加回答
舉報(bào)