-
Notifications
You must be signed in to change notification settings - Fork 0
/
react_demo02.html
26 lines (26 loc) · 982 Bytes
/
react_demo02.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div id="reactContainer"></div>
<script src="./common/react.js"></script>
<script src="./common/react-dom.js"></script>
<script src="https://cdn.bootcss.com/babel-core/5.8.38/browser.js"></script>
<script type="text/babel">
var HelloComponent = React.createClass({
render:function(){
// 支持三元和二元表达式 不支持if else
// return <h1>Hello {this.props.name?this.props.name:'zk'}</h1>
return <h1>Hello {this.props.name || 'zk'}</h1>
}
});
ReactDOM.render(<HelloComponent name="zengkai"/>,document.getElementById('reactContainer'))
</script>
</body>
</html>