通过将每个项目列表对象作为其 React 组件(名为 ProjectsItem)中的 prop 传递,然后将其映射到其<li>
标签中的每个项目信息对象<ul>
:
最后出错了
介绍.js 文件
项目列表(对象):
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: "" }],
}]);
它总是只显示一个项目,或者当我像这样时它会引发错误
project.projectInfos.map 不是一个函数
当我尝试通过更改 .map 位置来修复它时,例如
project.map((infos) => <li>{infos.projectInfos.name})
project.map 不是一个函数
它也无法点火
projectInfo.map 不是函数
我试图通过给出一个简短的声明来总结,因为在我看来错误是在 Map() 中。
欣赏有关代码和改进技巧的提示
浮云间
相关分类