我的tsx中有以下bootstrap手风琴。我想阻止按钮不触发切换。
<div id="accordion">
<div className="card">
<div className="card-header"
id={this.props.collapseID}
data-toggle="collapse"
data-target={this.props.dataTargetID}
aria-expanded="true"
aria-controls="collapseOne">
<div className="clearfix">
<h4 className="mb-0">
<a href={URL} target="_blank">
<strong>
Accordion Title
</strong>
</a>
<div className="statusCircle"></div>
</h4>
<div className="btn-grp">
<Button type="button" className="btn btn-primary" caption="Deploy All Links" onClick={this.onButtonClick} />
</div>
</div>
<i className="collapseIcon fa fa-chevron-right fa-1x" aria-hidden="true"></i>
</div>
<div id={this.props.contentID} className="collapse show" aria-labelledby={this.props.collapseID} data-parent="#accordion">
<div className="card-body">
//Content
</div>
</div>
</div>
</div>
从我在网上看到的,你必须做event.stopPropagation以防止事件冒泡。因此,我为我的按钮组件编写了这个函数:
onButtonClick = (event: Event) => {
event.stopPropagation();
}
但这似乎并没有阻止翻转。 stopImmediatePropagation
和preventDefault
答案 0 :(得分:0)
@zerodarkthirty,对onClick使用以下定义:
AgentTeamID
5000
5001
5002
5003
5004
5006
5007
5008
5009
5011
5012
5013
5014
5016
5017
5018
5019
5020
5021
5022
5024
5025
5027
5028
5029
5030
5032
5033
5034
5035
5038
5039
5040
5041
5042
5043