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

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

ReactJs .map inside 地圖我只得到一個(gè)是數(shù)組的最后一個(gè)孩子而不是整個(gè)

ReactJs .map inside 地圖我只得到一個(gè)是數(shù)組的最后一個(gè)孩子而不是整個(gè)

aluckdog 2023-07-29 15:30:42
通過(guò)將每個(gè)項(xiàng)目列表對(duì)象作為其 React 組件(名為 ProjectsItem)中的 prop 傳遞,然后將其映射到其<li>標(biāo)簽中的每個(gè)項(xiàng)目信息對(duì)象<ul>:最后出錯(cuò)了介紹.js 文件項(xiàng)目列表(對(duì)象): const [frontEndProjects, setFrontEndProjects] = useState([{    projectInfos: [{ name: "Imobile Shop", href: "" }],    projectInfos: [{ name: "Portfolio template", href: "" }],    projectInfos: [{ name: "Responsive Design Practice", href: "" }],  }]);  const [machineLearningProjects, setMachineLearningProjects] = useState([{ projectInfos: [{ name: "Hazel AI", href: "" }] }]);  const [backEndProjects, setBackEndProjects] = useState([{    projectInfos: [{ name: "My Little Market", href: "" }],    projectInfos: [{ name: "Todo List app", href: "" }],  }]);  const [webScrapingProjects, setWebScrapingProjects] = useState([{    projectInfos: [{ name: "Business list", href: "" }],    projectInfos: [{ name: "Weather Scraper", href: "" }],    projectInfos: [{ name: "Amazon Price Tracker (done deployement soon)", href: "" }],  }]);  const [javaScriptProjects, setJavaScriptProjects] = useState([{    projectInfos: [{ name: "Javascript: Blackjack - Rock Paper Scissors", href: "" }],    projectInfos: [{ name: "Instagram clone ReactJs", href: "" }],    projectInfos: [{ name: "Facebook Messenger clone ReactJs", href: "" }],    projectInfos: [{ name: "Netflix clone ReactJs", href: "" }],    projectInfos: [{ name: "Amazon clone ReactJs", href: "" }],    projectInfos: [{ name: "Tinder clone ReactJs ( Under Dev )", href: "" }],    projectInfos: [{ name: "Youtube clone ReactJs (LIVE DEMO soon)", href: "" }],    projectInfos: [{ name: "Spotify clone ReactJs (LIVE DEMO soon)", href: "" }],  }]);    const [dataScienceProjects, setDataScienceProjects] = useState([{    projectInfos: [{ name: "Process workbook-Edting Excel files", href: "" }],  }]);它總是只顯示一個(gè)項(xiàng)目,或者當(dāng)我像這樣時(shí)它會(huì)引發(fā)錯(cuò)誤project.projectInfos.map 不是一個(gè)函數(shù)當(dāng)我嘗試通過(guò)更改 .map 位置來(lái)修復(fù)它時(shí),例如project.map((infos) => <li>{infos.projectInfos.name})project.map 不是一個(gè)函數(shù)它也無(wú)法點(diǎn)火projectInfo.map 不是函數(shù)我試圖通過(guò)給出一個(gè)簡(jiǎn)短的聲明來(lái)總結(jié),因?yàn)樵谖铱磥?lái)錯(cuò)誤是在 Map() 中。欣賞有關(guān)代碼和改進(jìn)技巧的提示
查看完整描述

1 回答

?
浮云間

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

  const [frontEndProjects, setFrontEndProjects] = useState([

    { name: "Imobile Shop", href: "" },

    { name: "Portfolio template", href: "" },

    { name: "Responsive Design Practice", href: "" },

  ]);


  const [machineLearningProjects, setMachineLearningProjects] = useState([

    { name: "Hazel AI", href: "" },

  ]);


  const [backEndProjects, setBackEndProjects] = useState([

    { name: "My Little Market", href: "" },

    { name: "Todo List app", href: "" },

  ]);


  const [webScrapingProjects, setWebScrapingProjects] = useState([

    { name: "Business list", href: "" },

    { name: "Weather Scraper", href: "" },

    { name: "Amazon Price Tracker (done deployement soon)", href: "" },

  ]);


  const [javaScriptProjects, setJavaScriptProjects] = useState([

    { name: "Javascript: Blackjack - Rock Paper Scissors", href: "" },

    { name: "Instagram clone ReactJs", href: "" },

    { name: "Facebook Messenger clone ReactJs", href: "" },

    { name: "Netflix clone ReactJs", href: "" },

    { name: "Amazon clone ReactJs", href: "" },

    { name: "Tinder clone ReactJs ( Under Dev )", href: "" },

    { name: "Youtube clone ReactJs (LIVE DEMO soon)", href: "" },

    { name: "Spotify clone ReactJs (LIVE DEMO soon)", href: "" },

  ]);

  

  const [dataScienceProjects, setDataScienceProjects] = useState([

    { name: "Process workbook-Edting Excel files", href: "" },

  ]);




function ProjectsItem(props) {

  <div className="project-inner-container">

    <ul>

      {props.projects.map((project) =>

        (<li>{project.name}</li>))}

    </ul>

  </div>

}

這應(yīng)該可以做到。我刪除了projectInfos,因?yàn)檫@里不需要它,但如果您出于某種原因需要它,


[

  { projectInfo: { name: "name1", href: "" } },

  { projectInfo: { name: "name2", href: "" } },

]


{props.projects.map((project) =>

  (<li>{project.projectInfo.name}</li>))}

會(huì)做的。


查看完整回答
反對(duì) 回復(fù) 2023-07-29
  • 1 回答
  • 0 關(guān)注
  • 167 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(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)