freeCodeCamp/guide/chinese/react/installation/index.md

38 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: Installation
localeTitle: 安装
---
## 安装React
### 创建一个新的React项目
您可以在您的网页中嵌入React库如下所示2
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.0.0/cjs/react.production.min.js"></script>
```
聪明的程序员希望采用更实用,更高效的方式: [创建React App](https://github.com/facebookincubator/create-react-app)
```bash
npm install -g create-react-app
create-react-app my-app
cd my-app
npm start
```
这将设置您的开发环境以便您可以使用最新的JavaScript功能提供良好的开发人员体验并优化您的应用程序以进行生产。
`npm start`将启动一个允许实时重新加载的开发服务器3 。
完成项目并准备将应用程序部署到生产环境后,您就可以使用了 `npm run build` 在`build`文件夹中创建应用程序的优化版本。
#### 有用的链接
[创建React App存储库](https://github.com/facebookincubator/create-react-app#create-react-app-)
#### 来源
[1.关于安装的React教程](https://reactjs.org/docs/installation.html) [2.链接到cdnjs.org上的React最小JavaScript库](https://cdnjs.com/libraries/react) [3\. npm start命令](https://docs.npmjs.com/cli/start)