1 基础环境
1 React 开发中的, 企业级应用框架 (UmiJS)
2 快速上手 -> umi 3.x
--------------------------------------------------------------------------------------
1 mkdir my-umi
2 cd my-umi
3 npm create @umijs/umi-app
4 npm i / tyarn
5 tyarn start / npm start
--------------------------------------------------------------------------------------
3 常用的配置修改
--------------------------------------------------------------------------------------
1 hash
1 取值有俩个 -> true / false (默认)
2 配置是否让生成的文件包含 hash 后缀, 通常用于增量发布和避免浏览器的加载缓存
2 base
1 设置路由前缀, 通常用于部署到非根目录
3 history
1 取值为 json 对象, 默认值为: {
type: 'browser'}
2 type -> 可选: browser, hash, memory
4 outputPath
1 取值为字符串, 默认为 dist
2 指定输出路径
5 publicPath
1 取值为字符串, 默认为 '/'
2 配置 publicPath
6 title
1 配置标题
--------------------------------------------------------------------------------------
2 项目目录结构
# 项目根目录
## dist
## mock
## public
## src
### .umi
### layouts/index.tsx
### pages
### app.ts
## .deitorconfig
## .gitignore
## .env
## .prettierignore
## .prettierrc
## .umirc.ts
## package.json
3 路由配置
1 简单配置项
--------------------------------------------------------------------------------------
{
exact: true,
path: '/user',
component: 'user',
redirect: 'login',
title: 'xxx',
routes: [
{
path: '/about',
component: 'about'
},
]
}
--------------------------------------------------------------------------------------
1 配置路由
--------------------------------------------------------------------------------------
export default {
routes: [
{
exact: true, path: '/', component: 'index' },
{
exact: true, path: '/user', component: 'user' },
],
}
--------------------------------------------------------------------------------------
2