proyecto de construcción de andamios de reacción

Construcción ambiental (andamio oficial)

可以使用npm,建议使用yarn
1. Instale el hilo y reinicie (no reinicie, es posible que no se utilicen otras letras de unidad)
Abra cmd (pequeña caja negra) y ejecute el siguiente comando

//查询当前镜像
yarn config get registry 
//设置为淘宝镜像
yarn config set registry https://registry.npm.taobao.org/
//设置为官方镜像
//yarn config set registry https://registry.yarnpkg.com

2. Instale la aplicación create-react-app

//官方 不在支持 把CRA4.0安装到全局了,需要安装最新版CRA到全局

yarn global add create-react-app 
或
npm install create-react-app	-g //非安装包安装的yarn 推荐

//测试是否成功
create-react-app -V

3. Crea un proyecto de reacción

create-react-app 目录 | npx create-react-app 目录 | npm init react-app 目录

yarn eject   解构出所有的配置文件 可选
yarn start |  npm start 			开发
yarn build |  npm run build	 打包

//调试 需要安装给chrome浏览器一个插件 react-dev-tools  谷歌助手->chrome商店-搜索

Análisis ambiental

  • reaccionar: el paquete principal, demostración del componente de análisis
  • react-dom: el compilador -> Demostración del navegador
  • react-scrpts: reaccionar configuración del entorno del proyecto
  • Cuando manifest.json genera un acceso directo en el escritorio para una página web, el contenido de este archivo se utilizará como contenido de visualización del icono y el texto.
  • registerServiceWorker.js admite el acceso sin conexión, por lo que la experiencia de usarlo es muy similar a la de la aplicación nativa. RegisterServiceWorker.js solo será efectivo cuando la versión en línea del proyecto react esté empaquetada y generada. El servidor debe utilizar el protocolo https
  • La compatibilidad con Internet Explorer 9, 10 y 11 requiere un polyfill
    可能会遇到的错误
运行yarn 提示“不是内部或外部命令,”
	装完重启
  
create-react-app 提示“不是内部或外部命令,” //yarn无法全局安装包
	npm i create-react-app  -g      用npm重装
  
create-react-app 能用安装到一半报错(error)
	node 全量安装  ,一路下一步安装过程中有个复选框选中,时长30分钟
	
yarn eject
报git错误时: 
	git init -> git add . -> git commit -m 'init' -> yarn eject

报缺少babel 包: 安装一下(yarn add xxx -S)

配置
修改端口
//修改script/start.js
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3001;

去除eslint 警告(建议不要去除)
//config/webpack.config.js
//注释关于eslint的导入和rules规则 (react16.x)
//注释关于new ESLintPlugin (react17.x)

Andamios de terceros

yomen / umi

Construido manualmente por webpack

Supongo que te gusta

Origin blog.csdn.net/qq_38980678/article/details/115336430
Recomendado
Clasificación