第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

顯示嵌套的 Json 數(shù)組獲取的數(shù)據(jù) React native

顯示嵌套的 Json 數(shù)組獲取的數(shù)據(jù) React native

Qyouu 2022-06-05 15:48:34
所以我是反應(yīng)原生的新手,我試圖顯示 Json 獲取數(shù)據(jù)的嵌套元素,但我不知道該怎么做。在 fetch api 中使用 react hooks 后:export default function MedProfilScreen({ route }) {  //const {id,name,specialite,work}=route.params;  const [data, setData] = useState([]);  useEffect(() => {    fetch("http:......")      .then(response => response.json())      .then(res => {        setData(          res);        console.log(res);      })      .done();  },[]);}我得到了這個(gè)回復(fù):Array [  Object {    "code": "12459552",    "id": 7,    "name": "Dr xavier vilan",    "speciality": "Cardio",  },  Object {    "education": Array [      Object {        "date_debut": "2020-02-07",        "date_end": "2020-02-06",        "diploma": "asmaa",        "school": "asmaa",        "city": "vullez",      },      ]}]所以我想顯示例如:姓名:xavier 博士.. 文憑:asmaareturn(<View>  name: Dr xavier.. diploma: asmaa            </View>)任何人都知道該怎么做。謝謝
查看完整描述

3 回答

?
qq_笑_17

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>

);

輸出:

http://img1.sycdn.imooc.com//629c5fec000146d503060054.jpg

查看完整回答
反對(duì) 回復(fù) 2022-06-05
?
慕容708150

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


查看完整回答
反對(duì) 回復(fù) 2022-06-05
?
GCT1015

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超4個(gè)贊

嘗試這個(gè):


return (

   <View>{JSON.stringify(data, null, 2)}</View>

)


查看完整回答
反對(duì) 回復(fù) 2022-06-05
  • 3 回答
  • 0 關(guān)注
  • 131 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)