组件

Reads: 497 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">

function Welcome(props) {
    return <h1>Hello, {props.name}</h1>
}

function App() {
    return (
        <div>
            <Welcome name="Bob"/>
            <Welcome name="Alice"/>
            <Welcome name="Tom"/>
        </div>
    )
}

ReactDOM.render(
    <App/>,
    document.getElementById('root')
);

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

Comments

Make a comment