【发布时间】:2019-02-04 07:28:35
【问题描述】:
当我使用 react-select 时,有没有办法显示为什么一个选项被禁用? 选项对象中的 disabledReason 属性之类的东西?
【问题讨论】:
标签: reactjs react-select
当我使用 react-select 时,有没有办法显示为什么一个选项被禁用? 选项对象中的 disabledReason 属性之类的东西?
【问题讨论】:
标签: reactjs react-select
假设您想在菜单中的禁用选项旁边显示原因,您可以覆盖选项的呈现方式,以包含原因的方式呈现。
如何使用 react-select API 准确执行此操作取决于您使用的是 react-select 的 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
【讨论】:
一种可能的解决方案是
如果 react-select 被禁用,显示工具提示
In React, onMouseEnter or hover is not working as expected
【讨论】: