react js初级入门hello world

React JS离线转换依赖于npm(基于mac):

1、检查是否安装node:node -v

2、安装homebrew,打开终端,执行以下命令:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

3、安装node:brew install node,执行该命令后,node和npm自动安装好

4、在项目文件下,执行npm init,生成package.json文件

5、先安装命令行工具:npm install -g react-tools

6、将自己的js/helloworld.js转成标准的JavaScript文件:jsx --watch js/ bulid/

7、html Code:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Hello React!</title>
    <script src="build/react.js"></script>
    <script src="build/react-dom.js"></script>
  </head>
  <body>
    <div id="example"></div>
    <script src="build/helloworld.js"></script>
  </body>
</html>

8、Js/helloworld.js Code

 

ReactDOM.render(
  <h1>Hello, world!</h1>,
  document.getElementById('example')
);

一旦修改了自己的helloworld.js文件,build/helloworld.js文件会自动随之生成

以上就简单的在页面打印出Hello,world!

参考:http://reactjs.cn/react/docs/getting-started.html

 

转载于:https://www.cnblogs.com/ccMelissa/p/5629817.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值