AntDesign(React)學習-8 Menu使用 切換框架頁內容頁面


本節實現一個點擊左側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、運行正常

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM