对于React的看法
前提 tí) – assumption, prerequisite
我会写下我学到的关于React的知识。
本题
React是一种JavaScript库。
React.js是Facebook公开的用于创建UI组件视图功能的库。
特点
React有一种称为JSX的语法。
使用JavaScript的语法来操作DOM元素时阅读起来很困难,但是通过JSX,HTML和JavaScript融为一体,使得DOM元素的设计图更易于人类阅读。
仅显示差异以加快速度。
由于某种原因,React能够自动检测到页面的变化,并且只重新显示差异部分,因此显示速度非常快。
单向数据流
在React中,数据通常通过父组件向子组件单向传递。这种单向数据流的思想使得在不同的DOM元素之间更容易管理数据一致性,避免了数据不一致的问题。
安装React
首先,确认是否已安装Node和npx。
$ node -v
$ npx -v
使用React库创建应用程序
$ npx create-react-app アプリ名
...
...
success Uninstalled packages.
✨ Done in 4.61s.
Initialized a git repository.
Success! Created アプリ名 at /Users/username/Desktop/works/アプリ名
Inside that directory, you can run several commands:
yarn start
Starts the development server.
yarn build
Bundles the app into static files for production.
yarn test
Starts the test runner.
yarn eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can’t go back!
We suggest that you begin by typing:
cd アプリ名
yarn start
Happy hacking!
安装完成!
转到创建的应用程序并启动服务器!
$ cd アプリ名
$ npm start
若能夠訪問到 localhost:3000,並成功啟動 React 畫面,則完成!