官方create-react-app 入门(一)

目的:

  1. 但愿找到像Vue-cli相似的脚手架,便于入门。
  2. 经过此项目学习React。

参考地址:

https://github.com/facebook/c...react

系统:

macOSgit

过程:

  • 将npm升级到5.2以上,将有一个新的包,npx。npx 会自动查找当前依赖包中的可执行文件,若是找不到,就会去
    PATH里找。若是依然找不到,就会帮你安装。

    npx create-react-app my-appgithub

clipboard.png

cd 目录地点



npm start

运行开发环境npm

npm test

测试json

npm run build

运行发布环境。
我此次暂且选在Github Pages充当发布环境。app

GitHub Pages

  • 在package.json中添加homepage

    "homepage": "https://myusername.github.io/my-app",学习

    或者 "homepage": "https://myusername.github.io",测试

  • Install gh-pages and add deploy to scripts in package.json
npm install --save gh-pages



"scripts": { "predeploy": "npm run build", "deploy": "gh-pages -b master -d build", }
  • Deploy the site by running npm run deploy
npm run deploy
  • Ensure your project’s settings use gh-pages

结果就能够在Gighubpage中看到发布后的项目。ui

第一次写博客文章,但愿能坚持下去养成习惯,让本身变成本身但愿的人。spa

相关文章
相关标签/搜索