我刚开始接触ReactJS,我试图触发按钮上的onCLick
事件:如何在React类上定义事件处理程序?
/**
* @jsx React.DOM
*/
var ExampleApplication = React.createClass({
render: function() {
var message ='Joko';
return <div><p>{message}</p><button onClick=function() {console.log("hi")}>hier</button></div>;
}
});
React.renderComponent(
<ExampleApplication />,
document.getElementById('container')
);
我怎样才能显示console.log
消息,并触发onClick
事件?我得到的错误是:
Uncaught Error: Parse Error: Line 9: XJS value should be either an expression or a quoted XJS text
at http://localhost:63343/react-0.11.2/examples/basic-jsx-external/example.js:9:53