首页 > Web开发 > 详细

[React] React Fundamentals: Precompile JSX

时间:2015-08-27 21:09:13      阅读:241      评论:0      收藏:0      [点我收藏+]

The JSX Transformer library is not recommended for production use. Instead, you‘ll probably want to precompile your JSX into JavaScript.

 

Install:

npm install react-tools -g

 

Run:

jsx dev build --no-cache-dir --watch

//watch dev dir and compile js to build dir

 

You also need to change html a little bit:

 

dev/index.html

<!doctype html>
<html lang="en">
<head>
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="style.css"/>
    <script src="//fb.me/react-0.13.3.js"></script>
    <script src="//fb.me/JSXTransformer-0.13.3.js"></script>
    <meta charset="utf-8">
    <title>Compiler Dev</title>
</head>
<body>
<script  type="text/jsx" src="app.js"></script>
</body>
</html>

build/index.html

<!doctype html>
<html lang="en">
<head>
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="style.css"/>
    <script src="//fb.me/react-0.13.3.js"></script>
    <!-- no jsx file included-->
    <meta charset="utf-8">
    <title>Compiler Dev</title>
</head>
<body>
<!-- no type="jsx/text" -->
<script src="app.js"></script>
</body>
</html>

 

[React] React Fundamentals: Precompile JSX

原文:http://www.cnblogs.com/Answer1215/p/4764462.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!