在過去的一個小時裏,我一直在試圖讓這個工作。 onClick任何按鈕都不起作用...我做錯了什麼?反應:點擊按鈕不起作用
const React = require('react');
class Questionnaire extends React.Component {
constructor (props) {
super(props);
this.state = { selectedSection: 0 };
}
selectSection (e) {
console.log(e);
}
render() {
return (
<div>
<div className='btn-group mr-2' role='group'>
<button className='btn btn-primary' onClick={this.selectSection}>A</button>
<button className='btn btn-secondary' onClick={this.selectSection}>B</button>
<button className='btn btn-secondary' onClick={this.selectSection}>C</button>
<button className='btn btn-secondary' onClick={this.selectSection}>D</button>
</div>
</div>
);
}
}
module.exports = Questionnaire;
我要指出,我使用它明確反應的-意見
是否有任何控制檯錯誤? –
沒有控制檯錯誤 – Navarjun
代碼似乎對我來說工作正常。什麼都沒有出現在你的盡頭? – Iruss