import React, { Component } from 'react'
class Example extends React.Component {
constructor(props){
super(props)
this.handleWinner = this.handleWinner.bind(this);
}
handleWinner(event){
event.preventDefault();
alert("Buttet Pressed")
}
render() {
return (
<td key=1><button onClick={this.handleWinner}>Click Me</button></td>
)
}
我的功能是Not Dispatching on Button Click
答案 0 :(得分:0)
您的render
功能缺少}
。
render() {
return(
<td key=1><button onClick={this.handleWinner}>Click Me</button></td>
)
}
答案 1 :(得分:0)
您尚未正确关闭括号
class Example extends React.Component {
constructor(props) {
super(props);
this.handleWinner = this.handleWinner.bind(this);
}
handleWinner(event) {
event.preventDefault();
alert("Buttet Pressed")
}
render() {
return <div key=1>
<button onClick={this.handleWinner}>Click Me</button>
</div>
}
}
ReactDOM.render(<Example />, document.getElementById('app'))