List 反应-列出道具没有的项目';t传递到渲染列表组件
我是React Js的新手,我尝试制作一个列表组件来注入不同的ListItems。 但是当物品通过时,道具不会通过。 出了什么问题 2017年12月更新List 反应-列出道具没有的项目';t传递到渲染列表组件,list,reactjs,components,listitem,List,Reactjs,Components,Listitem,我是React Js的新手,我尝试制作一个列表组件来注入不同的ListItems。 但是当物品通过时,道具不会通过。 出了什么问题 2017年12月更新 const List=(道具)=>{ const componentorender=props.component; 让内容=(); if(道具项目){ 内容=道具.项目.地图((项目,索引)=>( )); }否则{ 内容=(); } 返回( {content} ); } 常量列表项=(道具)=>( ); 常数el=[ {href:“
const List=(道具)=>{
const componentorender=props.component;
让内容=();
if(道具项目){
内容=道具.项目.地图((项目,索引)=>(
));
}否则{
内容=();
}
返回(
{content}
);
}
常量列表项=(道具)=>(
);
常数el=[
{href:“#”,图标:“fa-fa-phone”,名称:“bannana”},
{href:“#”,图标:“fa-fa-phone”,名称:“apples”}
];
ReactDOM.render(
,document.getElementById('app')
);
提前感谢我的朋友。您将
项目
拼错为项目
:
ReactDOM.render(
,document.getElementById('app')
);
好的,我自己找到的
只需通过:
<ComponentToRender key={`item-${index}`} {...item}/>
Hi Ming Soon,您是否介意帮助我了解为什么道具无法通过,例如名称、图标、href。。。