📅  最后修改于: 2022-03-11 14:55:12.108000             🧑  作者: Mango
class MouseTracker extends React.Component {
constructor(props) {
super(props);
this.handleMouseMove = this.handleMouseMove.bind(this);
this.state = { x: 0, y: 0 };
}
handleMouseMove(event) {
this.setState({
x: event.clientX,
y: event.clientY
});
}
render() {
return (
Move the mouse around!
The current mouse position is ({this.state.x}, {this.state.y})
);
}
}