react阻止事件冒泡 e.nativeEvent.stopImmediatePropagation();
class OuterClickExample extends React.Component {
onClickHandler(e) {
e.nativeEvent.stopImmediatePropagation(); // 阻止冒泡
}
render() {
return (
<div style={{width:300}}>
<button onClick={(e)=>{this.onClickHandler(e)}}>Select an option</button>
</div>
);
}
}
export default OuterClickExample