Bootstrap

使用React实现一个简洁的单页面功能

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>React Input Display</title>
</head>
<body>
<div id="root"></div>

<script src="https://unpkg.com/[email protected]/umd/react.development.js"></script>
<script src="https://unpkg.com/[email protected]/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/@babel/[email protected]/babel.min.js"></script>

<script type="text/babel">
    function App() {
        const [text, setText] = React.useState("");

        const handleChange = (event) => {
            setText(event.target.value);
        };

        return (
            <div style={{ textAlign: "center", marginTop: "50px" }}>
                <h1>Text Display</h1>
                <label>aa
                    <input type="text" value={text} onChange={handleChange} />
                </label>
                <p>{text}</p>
            </div>
        );
    }

    ReactDOM.render(<App />, document.getElementById("root"));
</script>
</body>
</html>

;