环境搭建

  • 安装 WebStorm
  • 安装 Node.js

创建 React Web 应用 Hello world

  • terminal 中以命令的形式安装 create-reac-app,安装后提示它不是内部命令,重启电脑后命令生效

npm install -g create-react-app

  • 使用命令创建自己的 react web 应用

npx create-react-app firstreactweb

打印日志:

npx: installed 63 in 3.5sCreating a new React app in I:\2019\playground\WebInAction\firstreactweb.Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
复制代码

其实工程的创建会一直卡在这里。原因是某些网络访问问题,有种解决方式是:修改npm 的 register 源,修改依赖库的下载源使用命令:

npm config set registry registry.npm.taobao.org

配置后可通过下面方式来验证是否成功

npm config get registry 或 npm info express

  • 启动已创建的应用框架 查看 terminal 打印的日志,使用 npm start 命令即可启动模板代码的简易页面。

打印日志:

    Creating a new React app in I:\2019\playground\WebInAction\helloreact.Installing packages. This might take a couple of minutes.Installing react, react-dom, and react-scripts...+react@16.8.6+react-dom@16.8.6+react-scripts@2.1.8added 1846 packages from 718 contributors and audited 36246 packages in 294.019sfound 63 low severity vulnerabilitiesrun `npm audit fix` to fix them, or `npm audit` for detailsInitialized a git repository.Success! Created helloreact at I:\2019\playground\WebInAction\helloreactInside that directory, you can run several commands:npm startStarts the development server.npm run buildBundles the app into static files for production.npm testStarts the test runner.npm run ejectRemoves this tool and copies build dependencies, configuration filesand scripts into the app directory. If you do this, you can’t go back!We suggest that you begin by typing:cd helloreactnpm startHappy hacking!
复制代码
  • 国际惯例:第一个工程 Hello World

在工程 helloreact 的 src 目录结构中找到 app.js 文件,然后在 <header></header> 标签中添加 p 标签元素:

<p>Hello World</p>
复制代码

terminal中调用 npm start 可以在浏览器(页面地址为 http://localhost:3000/) 中展示 Hello World 页面。

  • 参考
    webpack 构建 react 多页面应用
    基于 JavaScript 库构建用户界面
    create-react-app 慢的解决方法

[React] Web应用:Hello World相关推荐

  1. 小谈React、React Native、React Web

    React有三个东西,React JS 前端Web框架,React Native 移动终端Hybrid框架,React Web是一个源码转换工具(React Native 转 Web,并之所以特别提出 ...

  2. vue/react/web前端项目部署到阿里云服务器_nginx_pm2流程及部署前的准备

    前端开发完成的项目,不管是使用vue.react.或者是别的web项目,最终都是要部署到外网上,让用户可以通过域名来访问.这篇文章以一个 react 移动端的项目为例,讲怎样将自己本地的项目部署到阿里 ...

  3. 现代 React Web 开发实战——kanban实现卡片拖拽

    前提摘要: 学习宋一玮 React 新版本 + 函数组件 &Hooks 优先 开篇就是函数组件+Hooks 实现的效果如下: 学到第11篇了 照葫芦画瓢,不过老师在讲解的过程中没有考虑拖拽目标 ...

  4. React全家桶构建一款Web音乐App实战(九):皮肤切换

    这一节是这款React Web音乐App实战的最后一节:皮肤切换功能.皮肤切换是Web音乐App中一个与核心无关的功能,加入这个功能可以为应用增添不少趣味性 实现思路 实现皮肤切换功能的大致原理就是将 ...

  5. React 毁了 Web 开发?

    作者 | Ivan Lučin 译者 | 弯月      责编 | 欧阳姝黎 出品 | CSDN(ID:CSDNnews) 以下为译文: React 是一个很好的库,对于Web开发很重要,因为它引入了 ...

  6. 2018 react 大会_React Conf 2018的经验教训

    2018 react 大会 by Yangshun Tay 阳顺泰 React Conf 2018的经验教训 (Lessons Learned at React Conf 2018) I was fo ...

  7. react的导出是怎么实现的_22 个让 React 开发更高效更有趣的工具

    英文 | https://dev.to/jsmanifest/22-miraculous-tools-for-react-developers-in-2019-4i46翻译 | https://www ...

  8. 21个让React 开发更高效更有趣的工具

    原文:medium.com/better-prog- 译者:前端小智 为了保证的可读性,本文采用意译而非直译. 想优质文章请猛戳GitHub博客,一年百来篇优质文章等着你! 下列工具中的重要性与排序无 ...

  9. 使用 create-react-app 构建 react应用程序 (react-scripts)

    前言: create-react-app 是一个全局的命令行工具用来创建一个新的项目 react-scripts 是一个生成的项目所需要的开发依赖 一般我们开始创建react web应用程序的时候,要 ...

最新文章

  1. 输入textbox在datagridview显示结果_Excel输入正确的公式,计算出错,根本没计算解决技巧...
  2. 《编程小白的第一本python入门书》笔记 二
  3. w7计算机的工具栏爱那里,Win7系统如何在任务栏中添加爱心图标图文教程
  4. 手机照片导入电脑步骤_手机录屏及电脑录屏操作步骤
  5. 超图iserver登录密码忘记,重置密码
  6. 基于matlab 论文知网,基于MATLAB的校园图像处理与分析
  7. oracle打开scott用户_Oracle 11gR2中启动Scott用户的方法(推荐)
  8. html5中外描边怎么写,CSS3实现文字描边的2种方法(小结)
  9. (转) Linux(Centos7)yum安装最新mysql
  10. 20复变函数的积分(六)
  11. Rust: (作者 洛佳) 使用Rust编写操作系统(附录一):链接器参数
  12. 三维空间内点到直线的距离计算公式
  13. cameraLink
  14. 基于树莓派的sht20温湿度传感器应用(c语言)
  15. 华为鸿蒙杀毒,华为鸿蒙系统
  16. 软件加入使用时间_Adobe CC 2020 系列软件更新(Adobe Zii 2020 5.2.1)| Mac软件天堂
  17. CSDN文章转onenote笔记(markdown)
  18. 常量(Constant)
  19. 蓝牙mesh-拓扑结构
  20. C语言将CSR存储模式转为coo,将大型稀疏矩阵转换为COO时出错(Error converting large sparse matrix to COO)...

热门文章

  1. .classpath文件
  2. Retrofit2.0
  3. git warning: LF will be replaced by CRLF in 解决办法
  4. redhat7 Oracle 12C 安装
  5. 修改linux的时间可以使用date指令
  6. javaFX中解决填充(拉伸)问题
  7. Windows Server 2008 R2 SP1遗忘管理员密码后的解决方案
  8. 字符设备编号的注册分配
  9. 《虚拟机深入应用实践》已经出版
  10. 使用QT进行内存管理