[英]ReactJS - Event doesn't bind (Megaboilerplate)
我正在使用React 15.1.0,並且無法綁定事件。 我不知道我在做什么錯。 這是我的組件:
import React from 'react';
class PatientProfile extends React.Component {
constructor(props) {
super(props);
this.state = {isToggleOn: true};
this.onClick = this.handleClick.bind(this)
}
handleClick() {
console.log('this is:');
}
render() {
return (
<div>
<button onClick={this.onClick}>off</button>
</div>
);
}
}
export default PatientProfile;
我已經在線搜索過,在React官方網站上嘗試過樣本,但沒有成功。 我是否在已安裝的軟件包中缺少某些內容?
我剛剛發現我應該構建bundle.js(npm run build),然后將事件綁定
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.