【发布时间】:2021-09-28 14:44:08
【问题描述】:
我想用它作为我页面的导航, 但我不知道如何正确链接索引,
我已经尝试将 l 项目分开,但没有奏效 白,,
和
<List>
{['Home' , 'About', 'Services', 'Contact'].map((text, index) => (
<ListItem button key={text} >
<ListItemIcon>
{index === 0 && <HomeOutlinedIcon /> }
{index === 1 && <InfoOutlined/>}
{index === 2 && <SettingsOutlinedIcon />}
{index === 3 && <MailIcon/>}
</ListItemIcon>
<ListItemText primary={text} />
</ListItem>
))}
</List>
谁能告诉我如何在这个列表中正确地路由我的导航。
【问题讨论】:
-
我不确定索引位,但为什么不像
[{ text: 'Home', Component: HomeOutlinedIcon }, ...]这样构造你的数组并映射文本和组件而不担心索引?
标签: javascript reactjs material-ui jsx drawer