我有以下组件:
var React = require("react");
var CollectionsButtonActions = require("../actions/CollectionsButtonActions");
var CollectionsApp = React.createClass({
getInitialState: function () {
return {text: ''};
},
render: function () {
var that = this;
var buttonItem = <button
onClick={this._handleButtonClick}
>Test</button>;
return (
<div className="view">
<div className="anchor">
{buttonItem}
</div>
<div className="main">
<p>You currently don't have any collections set up,
<a href="/admin/collections/new">create one</a>
.</p>
<ul>
</ul>
</div>
</div>
)
},
_handleButtonClick: function (event) {
console.log('test');
//CollectionsButtonActions.loadCollections();
}
});
module.exports = CollectionsApp;
出于某种原因,_handleButtonClick 事件根本没有触发,我尝试了各种包含按钮的方法,但由于某种原因,这个按钮只是不想触发它的事件。我可以在 Flux TodoMVC 示例应用程序中看到类似的示例https://github.com/facebook/flux/blob/master/examples/flux-todomvc/js/components/Footer.react.js#L48工作,但由于某种原因,上面的代码,点击事件没有附加到按钮上。
有任何想法吗?