我想停止点击事件.因此,我在代码中添加了e.stopPropagation().我总是在控制台上出错,上面写着:Uncaught TypeError: e.stopPropagation is not a function
在reactjs中设置StopRoPagation的正确方法是什么?
handleClick: function(index, e) {
e.stopPropagation();
...
},
我想停止点击事件.因此,我在代码中添加了e.stopPropagation().我总是在控制台上出错,上面写着:Uncaught TypeError: e.stopPropagation is not a function
在reactjs中设置StopRoPagation的正确方法是什么?
handleClick: function(index, e) {
e.stopPropagation();
...
},
正确的方法是使用.stopPropagation
,
var Component = React.createClass({
handleParentClick: function() {
console.log('handleParentClick');
},
handleChildClick: function(e) {
e.stopPropagation();
console.log('handleChildClick');
},
render: function() {
return <div onClick={this.handleParentClick}>
<p onClick={this.handleChildClick}>Child</p>
</div>;
}
});
事件处理程序将被传递给SyntheticEvent的实例