我有一些JS如下.我发现如果删除mdl-js-layout,按钮的onClick就可以了.否则它会失败.为什么会这样?我已经做过componentHandler.upgradeDom()
'use strict'; module.exports = React.createClass({ componentDidMount: function() { console.log('update') componentHandler.upgradeDom(); },addExpense: function() { console.log('add expense'); },render: function() { return ( <div ref="appLayout" className="mdl-layout mdl-js-layout mdl-layout--fixed-drawer"> <div className="mdl-layout__drawer"> <span className="mdl-layout-title">Expenses</span> <nav className="mdl-navigation"> <a className="mdl-navigation__link" href="#">Expenses</a> <a className="mdl-navigation__link" href="#">Settings</a> </nav> </div> <main className="mdl-layout__content"> <div className="page-content"> <div className="mdl-grid"> <div className="mdl-cell mdl-cell--12-col"> <button ref="btnAddExpense" onClick={this.addExpense} className="mdl-button mdl-js-button mdl-button--raised mdl-button--accent"> Add Expense </button> </div> </div> </div> </main> </div> ); } });
如果我查看React调试器工具,我实际上可以看到onClick应该绑定?