【问题标题】:React Select 2 - Portal menu positioningReact Select 2 - 门户菜单定位
【发布时间】:2018-11-27 02:15:42
【问题描述】:

是否可以控制 React-Select 2 的菜单定位?我在 React Virtualized 表行中使用它,但随后我将下拉菜单呈现到行外的门户。我已将 menuPosition 设置为 fixed 但 React-Select 2 延迟了自动定位,这太慢了,所以我想自己控制定位。

【问题讨论】:

    标签: react-select react-virtualized


    【解决方案1】:

    您可以通过向您的 Select 添加样式属性来覆盖组件样式,以组件为目标。 React-Select 使用emotionCSS 进行样式设置,而不是类,因此它可以关闭状态更改。

    const styles = {
      menuPortal: (base, state) => {
        let overrideProps = {};
        // do something here 
        return Object.assign(base, overrideProps);
      }
    };
    
    <Select styles={styles} />
    

    您可以在文档的Styles section 中找到更多信息。

    【讨论】:

      猜你喜欢
      • 2019-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-18
      • 2020-06-21
      • 1970-01-01
      • 1970-01-01
      • 2017-06-23
      相关资源
      最近更新 更多