我不知道为什么点击事件不是 firing.can 谁能帮帮我
i dont know why click event is not firing.can anyone help me please
enter image description here
谁能解决这个问题enter image description here
我检查了你的代码并修复了问题:
import React, { Component } from 'react';
export default class Classcompo extends Component {
constructor(props) {
super(props);
this.state = {
message: 'welcome visitors',
};
}
changeMessage() {
this.setState({
message: 'ok',
});
}
render() {
return (
<div>
<h1>{this.state.message}</h1>
<button onClick={() => this.changeMessage()}>CLICK</button>
</div>
);
}
}
enter image description here 谁能解决这个问题enter image description here
我检查了你的代码并修复了问题:
import React, { Component } from 'react';
export default class Classcompo extends Component {
constructor(props) {
super(props);
this.state = {
message: 'welcome visitors',
};
}
changeMessage() {
this.setState({
message: 'ok',
});
}
render() {
return (
<div>
<h1>{this.state.message}</h1>
<button onClick={() => this.changeMessage()}>CLICK</button>
</div>
);
}
}