React尝试案例二 ! DOCTYPE html html head meta charset = "UTF-8" / title Hello React ! / title ReactDOM . render ( h1 Hello , world ! / h1 , / / JSX document . getElementById ( 'example' ) ); / / JSX const element0 = h2 hello , react .
React尝试案例二
<!DOCTYPE html><html>
<head>
<meta charset="UTF-8" />
<title>Hello React!</title>
ReactDOM.render(
<h1>Hello, world!</h1>,
// JSX
document.getElementById('example')
);
// JSX
const element0 = <h2>hello, react.</h2>
ReactDOM.render(
element0,
document.getElementById("mine")
)
const name = "huyuxuan"
const element1 = <h2>by, {name}</h2>
// render
ReactDOM.render(
element1,
document.getElementById("mine0")
)
</script>
</head>
<body>
<div id="example"></div>
<div id="mine">
</div>
<div id="mine0"></div>
</body>
</html>
<!--
function formatName(user) {
return user.firstName + ' ' + user.lastName;
}
const user = {
firstName: 'Harper',
lastName: 'Perez'
};
const element = (
<h1>
Hello, {formatName(user)}!
</h1>
);
ReactDOM.render(
element,
document.getElementById('root')
); -->