有bug的代码:
<div className={`${cls}-containier-handle`}>
<Button disabled={curIndex === 0} onClick={this.handlePre}>上一个</Button>
<Button className={`${cls}-containier-handle-nextBtn`} disabled={curIndex === subProjectList.length - 1} onClick={this.handleNext}>下一个</Button>
<Popover
trigger="hover"
content={list}
direction="bottomCenter"
>
<div className={`${cls}-containier-handle-icon`} style={{ opacity: curIndex === subProjectList.length - 1 ? '.4' : '', transition: 'all .3s linear' }} />
</Popover>
</div>按钮效果:![]()
问题复现:当左侧按钮的disabled为true时,鼠标从左侧按钮移到右侧按钮时,右侧按钮的onMouseEnter事件不触发,导致没有hover的弹出效果。
原因:可能是被禁用的元素不会触发其他的事件。
解决办法:不使用原生的disabled的方法,自己去写禁用的逻辑并且加上禁用的样式。
版权声明:本文为weixin_47292253原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。