-
Notifications
You must be signed in to change notification settings - Fork 0
/
button.html
77 lines (55 loc) · 1.36 KB
/
button.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> React! React</title>
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/[email protected]/babel.min.js"></script>
<style>
#container {
padding: 50px;
background-color: #EEE;
}
#container {
font-size: 14px;
font-family: sans-serif;
color: #0080A8;
}
</style>
</head>
<body>
<div id="container"></div>
<script type="text/babel">
class ButtonGroup extends React.Component {
constructor(props) {
super(props);
this.state = {
buttonText: ''
};
}
handleClick = (event) => {
// Обработчик клика на кнопку
const buttonText = event.target.textContent;
this.setState({ buttonText });
};
render() {
return (
<div>
<button onClick={this.handleClick}>Кнопка 1</button>
<button onClick={this.handleClick}>Кнопка 2</button>
<button onClick={this.handleClick}>Кнопка 3</button>
<p>Текст кнопки: {this.state.buttonText}</p>
</div>
);
}
}
ReactDOM.render(
<div>
<ButtonGroup/>
</div>,
document.querySelector("#container")
);
</script>
</body>
</html>