Ant Design Pro 的初始化

Ant Design Pro 的初始化
Ohheng查看 官方文档
安装初始化脚手架
1
2使用 npm
npm i @ant-design/pro-cli -g打开将要存放项目的文件夹 创建项目
1
pro create linksauce-frontend
选择umi版本
1
2
3? 🐂 使用 umi@4 还是 umi@3 ? (Use arrow keys)
❯ umi@4
umi@3安装yarn
1
2全局安装
npm install -g yarn查看yarn版本
1
yarn -version
安装依赖
1
yarn
运行测试
package.json中的start项目瘦身,有坑,可跳过!!!
运行
package.json中的i18n-remove去除国际化,手动删除src\locales如果报错,检查一下是不是没删干净,可以手动去除
AntDesign去国际化 后 router页面显示问题:
解决方法:执行
yarn add eslint-config-prettieryarn add eslint-plugin-unicorn然后修改
node_modules/@umijs/lint/dist/config/eslint/index.js// es2022: true把这个注释掉就可以解决问题
如果不行,修改
config\routes.ts如下即可:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17export default [
{ name: '登录', path: '/user', layout: false, routes: [{ path: '/user/login', component: './User/Login' }] },
{ name: '欢迎页面', path: '/welcome', icon: 'smile', component: './Welcome' },
{
path: '/admin',
icon: 'crown',
access: 'canAdmin',
name: '管理员页面',
routes: [
{ path: '/admin', redirect: '/admin/sub-page' },
{ path: '/admin/sub-page', component: './Admin' },
],
},
{ icon: 'table', path: '/list', component: './TableList', name: '表格页' },
{ path: '/', redirect: '/welcome' },
{ path: '*', layout: false, component: './404' },
];删除
src\tests
重新安装依赖,重复第五步,确认是否能正常运行
1
yarn






