Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React学习之路 -- React脚手架搭建项目 #21

Open
hezizi opened this issue Nov 23, 2018 · 0 comments
Open

React学习之路 -- React脚手架搭建项目 #21

hezizi opened this issue Nov 23, 2018 · 0 comments

Comments

@hezizi
Copy link
Owner

hezizi commented Nov 23, 2018

前言

写此系列博客的目的是对所学React知识点的总结和梳理,包括填坑方案分享,希望能帮助到还并不会使用React的开发者入门React

React官方文档
React中文文档
React社区

项目搭建

按照官方提供的create-react-app搭建项目

  • 全局安装create-react-app

    cnpm i create-react-app -g

    cnpm i yarn -g
    yarn global add create-react-app

  • 全局安装后可以使用create-react-app这条命令

    创建react-demo文件夹
    create-react-app react-demo

  • 启动项目

    cd react-demo
    npm start

    yarn start

如果node 6+ 并且 npm 5.2+,可以使用npx安装

npx create-react-app react-demo

yarn create react-app react-demo (yarn 0.25+)
cd react-demo
npm start

目录结构

在这里插入图片描述

public/index.html页面入口文件,
src/App.js根组件,
src/App.css根组件样式文件,
src/index.js程序入口文件,
src/index.css页面样式文件,
App.test.jsserviceWorker.js暂时不会使用,可以删除

运行项目

yarn start

在这里插入图片描述

项目运行成功

下篇博客

React组件

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant