码迷,mamicode.com
首页 > 其他好文 > 详细

UMI学习-8 antd Menu点击 切换框架页内容页面

时间:2020-02-02 01:38:10      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:routes   from   png   角色   parent   角色管理   OLE   you   end   

本节实现一个点击左侧menu在右侧content切换页面效果,原始代码请从UMI学习-6开始看

1、在pages下添加两个组件,User,UserRole

import React from ‘react‘;
class User extends React.Component { 
  render() {
    return (
      <div>用户管理</div>
    );
  }
}
export default User;
import React from ‘react‘;
class UserRole extends React.Component { 
  render() {
    return (
      <div>角色管理</div>
    );
  }
}
export default UserRole;

2、修改umirc.ts routes部分如下

const config: IConfig =  {
  treeShaking: true,
  routes: [
    {
       path: ‘/mainfrm‘,
       component: ‘../layouts/BasicLayout‘,
       routes: [
        { path: ‘/mainfrm‘, component: ‘../pages/User‘ },
        { path: ‘/mainfrm/user‘, component: ‘../pages/User‘ },
        { path: ‘/mainfrm/userrole‘, component: ‘../pages/UserRole‘ },
      ]
    },
    {
      path: ‘/‘,
      component: ‘../layouts/index‘,
      routes: [
        { path: ‘/‘, component: ‘../pages/index‘ }
      ]
    }
  ],

3、修改leftmenutree中state代码为

class LeftMenuTree extends React.Component {
  state={list:[{"id":0,"title":"首页","url":"/","children":[]},{"id":1,"title":"权限配置","parentid":0,"children":[{"id":2,"title":"用户管理","url":"/mainfrm/user","parentid":1,"children":[]},{"id":3,"title":"角色管理","url":"/mainfrm/userrole","parentid":1,"children":[]}]}]};

4、运行正常

技术图片

 

 技术图片

 

UMI学习-8 antd Menu点击 切换框架页内容页面

标签:routes   from   png   角色   parent   角色管理   OLE   you   end   

原文地址:https://www.cnblogs.com/zhaogaojian/p/12250634.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!