禁用原因在反应,选择选项

问题描述 投票:0回答:2

有没有一种方法来说明为什么当我使用的反应,选择一个选项被禁用?类似的选项对象disabledReason财产?

reactjs react-select
2个回答
0
投票

假设你要显示在旁边的菜单中禁用选项的原因,你可以覆盖选项如何呈现在包括原因的方式来呈现。

如何做到这一点恰与反应选API,如果你使用的是V1或反应选的V2依赖。

例如,对于V1:https://github.com/JedWatson/react-select/blob/v1.x/examples/src/components/CustomComponents.js 对于V2文档:https://react-select.com/props#replacing-components


0
投票

一个可能的解决方案是

  1. 使用反应选择成分发生反应的SyntheticEvent OnMouseEnter在检查是否鼠标悬停时。
  2. 检查反应,选择组件被禁用
  3. 如果反应选被禁用,显示工具提示 In React, onMouseEnter or hover is not working as expected https://reactjs.org/docs/events.html#mouse-events tooltip div with ReactJS
© www.soinside.com 2019 - 2024. All rights reserved.