react管理系统layOut简单搭建

一、新建立react文件夹,生成项目

复制代码
npx create-react-app my-app
cd my-app
npm start

二、安装react-router-dom

复制代码
npm install react-router-dom

三、安装Ant Design of React(UI框架库,可根据需求进行安装)

复制代码
npm install antd --save

好的,现在前期工作准备得差不多了,开始搭建我们的页面

四、搭建页面

创建main页面,实现react LayOut总体布局

复制代码
import React, { useState } from 'react';
import {
  MenuFoldOutlined,
  MenuUnfoldOutlined,
  UploadOutlined,
  UserOutlined,
  VideoCameraOutlined,
} from '@ant-design/icons';
import { Layout, Menu, Button, theme } from 'antd';

const { Header, Sider, Content } = Layout;

const Main: React.FC = () => {
  const [collapsed, setCollapsed] = useState(false);
  const {
    token: { colorBgContainer },
  } = theme.useToken();

  return (
    <Layout >
      <Sider trigger={null} collapsible collapsed={collapsed}>
        <div className="demo-logo-vertical" />
//左侧标题栏
        <Menu
          theme="dark"
          mode="inline"
          defaultSelectedKeys={['1']}
          items={[
            {
              key: '1',
              icon: <UserOutlined />,
              label: '标题1',
            },
            {
              key: '2',
              icon: <VideoCameraOutlined />,
              label: '标题2',
            },
            {
              key: '3',
              icon: <UploadOutlined />,
              label: '标题3',
            },
          ]}
        />
      </Sider>
      <Layout>
        <Header style={{ padding: 0, background: colorBgContainer }}>
          <Button
            type="text"
            icon={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
            onClick={() => setCollapsed(!collapsed)}
            style={{
              fontSize: '16px',
              width: 64,
              height: 64,
            }}
          />
        </Header>
        <Content
          style={{
            margin: '24px 16px',
            padding: 24,
            minHeight: 500,
            background: colorBgContainer,
          }}
        >
          Content我们需要展示的页面
        </Content>
      </Layout>
    </Layout>
  );
};

export default Main;

页面布局总体搭建完成,下一张将写reacrt Menu跳转组件

相关推荐
用户69371750013844 分钟前
AI 帮我写了大半年的代码,我却越来越不会写代码了
前端·后端·github
skywalk816317 分钟前
把「假成功」赶出工具层:lightharness 两天升级复盘(4×5 模式矩阵 + 工具层 5 个缺陷)
开发语言·前端·人工智能·lightharness
彭亚川Allen42 分钟前
从零手搓 RAG:用 Elasticsearch 存储与检索向量
前端·后端·面试
jerrywus43 分钟前
15 个可以直接安装的 AI Agent Skills:按场景挑
前端·agent·claude
涛涛ing1 小时前
用了三年微前端,我们终于把它拆成了单体应用
前端
去伪存真2 小时前
《最终版》《打死不改版》全传一遍?RAG 系统文件去重实战
前端
anyup2 小时前
【全端支持】 uni-app x 专用请求库:axios 写法,多实例、拦截器、可中断、上传下载
前端·uni-app·unix
费曼学习法2 小时前
6 个 MCP Server 传输层重写实录:超时率 12% → 0.3%
前端·后端
htzyl2062 小时前
金额计算:为什么前端不该用浮点数存钱
前端·javascript·算法
Iseeyore2 小时前
Vue3 Vs React
前端·vue.js