React study notes (1)

In recent years, the front-end framework is divided into three parts: Angular, React, and Vue. Among them, React is the most popular. Because the new company requires the use of React, it has to put down Vue, which has not been learned for a few days, and start to study React.

The first step is to build the environment

There are two ways, first, directly download js files and introduce them in html; second, use webpack to build;

The first is very common, and here is the second method.

First, install node.js, just download and install it from the official website under Windows. Take Ubuntu16.04 as an example under Linux. Do not use apt-get to install it. Go to the official website to download the tar.gz package and unzip it to a certain directory.

Then execute the following two statements

 

 

$ ln -s /unzipped directory/bin/node /usr/local/bin/node
$ ln -s /unzipped directory/bin/npm /usr/local/bin/npm

 

 

The following two statements verify

$ node -v
v6.2.0
$ npm -v
3.8.9

 

If the version information appears, the installation is successful.

 

Generally speaking, node.js comes with npm, it is recommended to install Taobao's cnpm

For the installation method, please refer to the official website  http://npm.taobao.org/

After installing node.js, we install a scaffolding project provided by react to build the basic project structure

$ cnpm install -g create-react-app
$ create-react-app my-app
$ cd my-app/
$ npm start

 

The following output appears on the command line:

The app is running at:

  http://localhost:3000/

 

Visit http://localhost:3000/ in your browser to see the project running.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326837282&siteId=291194637