react中阻止按钮onClick的冒泡

jsx中代码:

<Icon type='plus' onClick={this.showAlbum} />

 对应的点击事件:

showAlbum = e => {
        e.stopPropagation();
        this.setState({
            albumVisible: true,
        });
    };

 看到了吗, 关键是 e.stopPropagation();

 

posted on 2020-05-11 15:12  清清飞扬  阅读(4203)  评论(0编辑  收藏  举报