打开React的门

2020-03-24  本文已影响0人  KenChen_939

一次学习,随处编写

无论你现在正在使用什么技术栈,你都可以随时引入 React 来开发新特性,而不需要重写现有代码。

React 还可以使用 Node 进行服务器渲染,或使用 React Native 开发原生移动应用

创建第一个react应用

使用 create-react-app 来创建应用。
创建和初始化 React 应用:

npm install -g create-react-app

create-react-app --version

create-react-app hackernews

cd hackernews

注意需要配置npm镜像,否则很慢

npm get registry            查看镜像源
npm config set registry http://registry.npm.taobao.org/            将镜像源设置为阿里

运行 & 测试:

#在http://localhost:3000 启动应用 
npm start
#运行所有测试 
npm test
#构建项目的产品文件 
npm run build

本回完。

上一篇 下一篇

猜你喜欢

热点阅读