The first appliaction for "Hello World!"

Each language in programing has it's own rules. For example, Java,node,php,python,angular,vue as well as react. Next come to with me to complete the application.

Environment Building

You can use yo,node and other packaging tools to build the environment. As I download before, so I can import them just like this.

The structure is like this.

Now let's start working with the API ReactDom.render(template,selector)

You can treat it as a html template to build a react application.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../js/bootstrap.css">
    <script src="../js/react.js"></script>
    <script src="../js/react-dom.js"></script>
    <script src="../js/browser.js"></script>
    <title>React</title>
</head>
<body>
<div id="example"></div>
<script type="text/babel">
</script>
</body>
</html>

Hello World

<div id="example"></div>
<script type="text/babel">
    ReactDOM.render(
            <h1>Hello, world!</h1>,
        document.getElementById('example')
    );
</script>

Ok, you will find the result in chrome.

You can change the world with your heart,even a lot of changes sometimes unless you won't geiv up....
原文地址:https://www.cnblogs.com/xiongwei2017/p/7350576.html