<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jsx语法</title>
</head>
<body>
<div id="app"></div>
<script src="node_modules/@babel/standalone/babel.js"></script>
<script src="node_modules/react/umd/react.development.js"></script>
<script src="node_modules/react-dom/umd/react-dom.development.js"></script>
<script type="text/babel">
const user = {
name: 'Jack',
age: 18,
gender: 0
}
// #region /在 JavaScript 中嵌入 jsx
// **********************
function getGreeting (user) {
if (user) {
return <h1>hello {user.name}</h1>
}
return <h1>Hello Stranger</h1>
}
const element = getGreeting(null)
ReactDOM.render(
element,
document.getElementById('app')
)
</script>
</body>
</html>