-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path类式组件.html
34 lines (31 loc) · 1.05 KB
/
类式组件.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
27
28
29
30
31
32
33
34
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script crossorigin src="https://cdn.bootcdn.net/ajax/libs/react/17.0.2/umd/react.development.js"></script>
<script crossorigin src="https://cdn.bootcdn.net/ajax/libs/react-dom/17.0.2/umd/react-dom.development.js"></script>
<script crossorigin src="https://cdn.bootcss.com/babel-standalone/6.26.0/babel.js"></script>
<title>Document</title>
</head>
<body>
<div id="test"></div>
</body>
<script type="text/babel">
class Weather extends React.Component{
state={isHot:false}
demo=()=>{
const {isHot}=this.state
this.setState({
isHot:!isHot
})
}
render(){
const {isHot}=this.state
return (<h2 onClick={this.demo}>天气{isHot?'热':'冷'}</h2>)
}
}
ReactDOM.render(<Weather/>,document.getElementById('test'))
</script>
</html>