元素渲染

Reads: 641 Edit

New wiki page content

<!-- learn react -->
----
<html>
<head>
    <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
    <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
</head>
<body>
    <div id="root"></div>
<script type="text/babel">

const clock = (
    // 一个React DOM元素只能有一个根元素,因此
    // <h1>和<p>必须用一个根元素包起来:
    <div>
        <h1>Clock</h1>
        <p>It is { new Date().toLocaleString() }</p>
    </div>
);

ReactDOM.render(
    clock,
    document.getElementById('root')
);

</script>
</body>
</html>

Comments

Make a comment