简体   繁体   English

如何使用#react-admin创建自定义页面而不使用登录页面等菜单侧栏?

[英]How can I create a custom page with #react-admin without the menu sidebar like login page?

I am using react-admin previously admin-on-rest. 我正在使用react-admin之前的admin-on-rest。 I want to create a custom page that doesn't show the Menu sidebar, like Login page. 我想创建一个不显示菜单侧边栏的自定义页面,例如登录页面。 I will use this page reset user's password. 我将使用此页面重置用户的密码。 How can I do that? 我怎样才能做到这一点?

This is not obvious in the documentation but the Route actually accepts a noLayout prop: 这在文档中并不明显,但Route实际上接受了noLayout道具:

<Admin
    customRoutes={[
        <Route
            path="/custom"
            component={CustomRouteNoLayout}
            noLayout
        />,
        <Route
            path="/custom2"
            component={CustomRouteWithLayout}
        />,
    ]}
>

Add a custom route with the component you want to render. 使用要渲染的组件添加自定义路径 When route is successful the specified component will be presented. 路线成功时,将显示指定的组件。 No Menu will be shown just whatever you have in the component you send as prop to Route . Menu将刚刚展示凡是你必须在你的道具发送到组件Route

The way you put the question it seemed like you were trying to have a custom page that hadn't a MenuItemLink in Menu . 您提出问题的方式似乎是您尝试在Menu一个没有MenuItemLink的自定义页面。 Had to reread the question to understand what you wanted. 不得不重读这个问题,以了解你想要什么。

I'd like to add on to Gildas Garcia's answer. 我想补充一下Gildas Garcia的回答。 After you added the customed routes as shown in the documentation, you need to add a hash # in front of the route url to be able to view the content. 添加自定义路由后,如文档中所示,您需要在路径URL前面添加一个哈希#才能查看内容。 For example, if you are displaying the view at localhost:3000/ , and one of your routes is 例如,如果您在localhost:3000/中显示视图,并且您的其中一条路线是

<Route exact path="/foo" component={Foo} />,

then you should go to localhost:3000/#/foo to view the content. 那么你应该去localhost:3000/#/foo查看内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM