【发布时间】:2021-03-30 07:29:21
【问题描述】:
在添加 webpack 之前这是有效的,在添加之后它就停止了。
export class Main extends Component {
constructor(props) {
super(props);
this.state = {
currentPage: states.allProducts
};
this.handleClick = this.handleClick.bind(this);
}
async componentDidMount() {
let currentPage = this.state.currentPage;
}
handleClick() {
alert('a');
}
render() {
return (
<button onClick={this.handleClick}>
Say hello
</button>
);
}
}
【问题讨论】:
-
状态对象中的消息键在哪里?