首页 > react 阻止冒泡行为

react 阻止冒泡行为

react 子控件点击触发了父控件的点击,在子控件的点击方法e.stopPropagation() e.preventDefault()阻止无效


http://stackoverflow.com/questions/24415631/reactjs-syntheticevent-stoppropagation-only-works-with-react-events

react自己写的onclick等应该是可以stop的


这应该是React的历史遗留问题,可能需要一个插件来解决:react-tap-event-plugin


<a href="#"  onClick={(event) => {
            event.preventDefault();
            handleClick();
        }}>
<a
   href="#"
   onClick={this.handelButtonClick.bind(this)}>
handelButtonClick(event) {
        event.preventDefault();
    }

可以这两两种写法

【热门文章】
【热门文章】