本文主要讲使用方法,以ant-design为例,
首先是安装脚手架,创建项目,然后初始化,有的需要安装依赖,之后启动项目,最后构建部署。
一般命令:
npm install xxx -g 安装xxx依赖包
npm install 安装依赖包
npm start 启动项目
npm run build 项目打包
例子:
测试项目demo,此处用npm做包管理
$ npm install antd-init -g 安装脚手架
$ mkdir antd-demo && cd antd-demo 创建项目
$ antd-init 初始化
安装缓慢报错时,rm -rf node_modules && cnpm install
npm start localhost:8000/或者http://127.0.0.1:8000查看
$ npm run build 构建和部署
https://ant.design/docs/react/getting-started-cn
demo2,这个使用yarn作为包管理
$ mkdir myapp && cd myapp
$ yarn create umi 等价 npm install -g create-umi && create-umi
$ yarn 安装依赖
$ yarn start 启动
$ yarn global add npx 安装npx,用于执行 node_modules 下的命令
$ npx umi g page products 创建 /products 路由
$ yarn start
http://localhost:8000/products 查看products页面
$ npm run build 部署
注释:
yarn安装依赖报错:error eslint@5.8.0: The engine “node” is incompatible with this module. Expected version “^6.14.0 || ^8.10.0 || >=9.10.0”.error Found incompatible module
解决方案:sudo yarn install --ignore-engines
https://blog.csdn.net/w903328615/article/details/79537524
对于要克隆项目的处理
$ git clone --depth=1 https://github.com/ant-design/ant-design-pro.git posSY
$ cd posSY
$ npm i
$ npm start
————————————————
版权声明:本文为CSDN博主「keep789」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/keep789/article/details/85574871