我是反应管理新手,如何创建可以从菜单侧边栏访问的自定义页面?我正在寻找与本教程类似的内容:https://marmelab.com/blog/2019/03/07/react-admin-advanced-recipes-user-profile.html https://marmelab.com/blog/2019/03/07/react-admin-advanced-recipes-user-profile.html但我需要能够像其他资源一样从左侧菜单侧栏中的图标访问该配置文件页面。谢谢
您需要使用菜单组件:
import React from 'react';
import { Layout, MenuItemLink, Responsive } from 'react-admin';
import MyAppbar from './MyAppbar';
import BookIcon from '@material-ui/icons/Book';
import SettingsIcon from '@material-ui/icons/Settings';
import ChatBubbleIcon from '@material-ui/icons/ChatBubble';
import LabelIcon from '@material-ui/icons/Label';
const menuItems = [
{ name: 'posts', text: 'Posts', icon: <BookIcon /> },
{ name: 'comments', text: 'Comments', icon: <ChatBubbleIcon /> },
{ name: 'tags', text: 'Tags', icon: <LabelIcon /> },
{ name: 'my-profile', text: 'My profile', icon: <SettingsIcon /> }
];
const MyMenu = ({ onMenuClick, logout }) => (
<div>
{ menuItems.map(item => (
<MenuItemLink
key={item.name}
to={`/${item.name}`}
primaryText={item.text}
leftIcon={item.icon}
onClick={onMenuClick}
/>
))}
<Responsive
small={logout}
medium={null}
/>
</div>
);
const MyLayout = props => <Layout {...props} menu={MyMenu} appBar={MyAppbar} />;
export default MyLayout;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)