搭建一个简单React全栈项目

112 阅读1分钟

1. 思考产品能力明确目标用户

image.png

2. 梳理项目架构

image.png

3. 搭建前端架构

前端搭建:React、Hooks、HTML、Css、TS、JavaScript、Axios、React-router

  • 通过npm install -g create-react-app
  • npx create-react-app 项目名 --template typescript
  • 通过React-router-dom搭建前端history路由(SEO有帮助),需要服务端配合
前端主体架构
---src
-----component(个功能模块)
-----img(base4图片存储)
-----lib(功能组件)
-----Router(路由)
-----App(页面导航)
-----index(Root挂载)

4. 搭建后台架构 后端技术 express、router、Sequelize、mysql2、apiFox、mysql workbench

** 准备工作**

image.png

image.png

后端主体机构

          |-----components(功能组件)
          |  
          | 
          |          -----config(数据库配置)
--src--   |----db -----migrations(建表)
          |          ----models(数据接口)
          |          -------seeders数据插入
          |
          |----router(router接口)
          |
          |----utils(公共组件)
          |
          |
          |---APP(主入口)

具体步骤 image.png