React-select 相关API属性用法

29 篇文章 1 订阅
15 篇文章 0 订阅

1. Control:控制输入框和下拉箭头的显示。
   ```jsx
   const CustomControl = (props) => (
     <components.Control {...props} />
   );

   <Select
     components={{ Control: CustomControl }}
   />
   ```

2. Option:自定义下拉选项的显示样式。
   ```jsx
   const CustomOption = (props) => (
     <components.Option {...props} />
   );

   <Select
     components={{ Option: CustomOption }}
   />
   ```

3. MultiValue:自定义多选下拉框中选中选项的显示样式。
   ```jsx
   const CustomMultiValue = (props) => (
     <components.MultiValue {...props} />
   );

   <Select
     components={{ MultiValue: CustomMultiValue }}
     isMulti
   />
   ```

4. Placeholder:自定义输入框中的占位符文本。
   ```jsx
   const CustomPlaceholder = (props) => (
     <components.Placeholder {...props} />
   );

   <Select
     components={{ Placeholder: CustomPlaceholder }}
   />
   ```

5. DropdownIndicator:自定义下拉箭头图标。
   ```jsx
   const CustomDropdownIndicator = (props) => (
     <components.DropdownIndicator {...props} />
   );

   <Select
     components={{ DropdownIndicator: CustomDropdownIndicator }}
   />
6. SingleValue:自定义单选下拉框中选中选项的显示样式。
   ```jsx
   const CustomSingleValue = (props) => (
     <components.SingleValue {...props} />
   );

   <Select
     components={{ SingleValue: CustomSingleValue }}
   />
   ```

7. Menu:自定义下拉菜单的整体样式和行为。
   ```jsx
   const CustomMenu = (props) => (
     <components.Menu {...props} />
   );

   <Select
     components={{ Menu: CustomMenu }}
   />
   ```

8. MenuList:自定义下拉菜单中选项列表的样式和行为。
   ```jsx
   const CustomMenuList = (props) => (
     <components.MenuList {...props} />
   );

   <Select
     components={{ MenuList: CustomMenuList }}
   />
   ```

9. ClearIndicator:自定义清除选项图标。
   ```jsx
   const CustomClearIndicator = (props) => (
     <components.ClearIndicator {...props} />
   );

   <Select
     components={{ ClearIndicator: CustomClearIndicator }}
   />
10. IndicatorSeparator:自定义指示器之间的分隔符。
    ```jsx
    const CustomIndicatorSeparator = (props) => (
      <components.IndicatorSeparator {...props} />
    );

    <Select
      components={{ IndicatorSeparator: CustomIndicatorSeparator }}
    />
    ```

11. LoadingIndicator:自定义加载指示器。
    ```jsx
    const CustomLoadingIndicator = (props) => (
      <components.LoadingIndicator {...props} />
    );

    <Select
      components={{ LoadingIndicator: CustomLoadingIndicator }}
    />
    ```

12. ValueContainer:自定义选中值的容器。
    ```jsx
    const CustomValueContainer = (props) => (
      <components.ValueContainer {...props} />
    );

    <Select
      components={{ ValueContainer: CustomValueContainer }}
    />
13. Group:自定义选项分组的显示样式。
    ```jsx
    const CustomGroup = (props) => (
      <components.Group {...props} />
    );

    <Select
      components={{ Group: CustomGroup }}
    />
    ```

14. GroupHeading:自定义选项分组的标题样式。
    ```jsx
    const CustomGroupHeading = (props) => (
      <components.GroupHeading {...props} />
    );

    <Select
      components={{ GroupHeading: CustomGroupHeading }}
    />
    ```

15. NoOptionsMessage:自定义没有匹配选项时显示的提示信息。
    ```jsx
    const CustomNoOptionsMessage = (props) => (
      <components.NoOptionsMessage {...props} />
    );

    <Select
      components={{ NoOptionsMessage: CustomNoOptionsMessage }}
    />
16. MultiValueLabel:自定义多选下拉框中选中选项的标签部分的样式。
    ```jsx
    const CustomMultiValueLabel = (props) => (
      <components.MultiValueLabel {...props} />
    );

    <Select
      components={{ MultiValueLabel: CustomMultiValueLabel }}
      isMulti
    />
    ```

17. MultiValueRemove:自定义多选下拉框中选中选项的移除按钮。
    ```jsx
    const CustomMultiValueRemove = (props) => (
      <components.MultiValueRemove {...props} />
    );

    <Select
      components={{ MultiValueRemove: CustomMultiValueRemove }}
      isMulti
    />
18. ClearIndicator:自定义清除选项的图标和行为。
    ```jsx
    const CustomClearIndicator = (props) => (
      <components.ClearIndicator {...props} />
    );

    <Select
      components={{ ClearIndicator: CustomClearIndicator }}
    />
    ```

19. LoadingMessage:自定义加载选项时显示的提示信息。
    ```jsx
    const CustomLoadingMessage = (props) => (
      <components.LoadingMessage {...props} />
    );

    <Select
      components={{ LoadingMessage: CustomLoadingMessage }}
    />
    ```

20. ValueContainer:自定义选中值的容器样式和行为。
    ```jsx
    const CustomValueContainer = (props) => (
      <components.ValueContainer {...props} />
    );

    <Select
      components={{ ValueContainer: CustomValueContainer }}
    />
21. Placeholder:自定义输入框中的占位符文本样式。
    ```jsx
    const CustomPlaceholder = (props) => (
      <components.Placeholder {...props} />
    );

    <Select
      components={{ Placeholder: CustomPlaceholder }}
    />
    ```

22. IndicatorSeparator:自定义指示器之间的分隔符样式。
    ```jsx
    const CustomIndicatorSeparator = (props) => (
      <components.IndicatorSeparator {...props} />
    );

    <Select
      components={{ IndicatorSeparator: CustomIndicatorSeparator }}
    />
    ```

23. SingleValue:自定义单选下拉框中选中选项的显示样式。
    ```jsx
    const CustomSingleValue = (props) => (
      <components.SingleValue {...props} />
    );

    <Select
      components={{ SingleValue: CustomSingleValue }}
    />
24. DropdownIndicator:自定义下拉箭头图标样式。
    ```jsx
    const CustomDropdownIndicator = (props) => (
      <components.DropdownIndicator {...props} />
    );

    <Select
      components={{ DropdownIndicator: CustomDropdownIndicator }}
    />
    ```

25. ClearValue:自定义清除选中值的图标和行为。
    ```jsx
    const CustomClearValue = (props) => (
      <components.ClearValue {...props} />
    );

    <Select
      components={{ ClearValue: CustomClearValue }}
    />
    ```

26. MenuPortal:自定义下拉菜单的渲染位置。
    ```jsx
    const CustomMenuPortal = (props) => (
      <components.MenuPortal {...props} />
    );

    <Select
      components={{ MenuPortal: CustomMenuPortal }}
    />
27. ValueContainer:自定义选中值的容器样式和行为。
    ```jsx
    const CustomValueContainer = (props) => (
      <components.ValueContainer {...props} />
    );

    <Select
      components={{ ValueContainer: CustomValueContainer }}
    />
    ```

28. MultiValueContainer:自定义多选下拉框中选中选项的容器样式。
    ```jsx
    const CustomMultiValueContainer = (props) => (
      <components.MultiValueContainer {...props} />
    );

    <Select
      components={{ MultiValueContainer: CustomMultiValueContainer }}
      isMulti
    />
    ```

29. DropdownIndicator:自定义下拉箭头图标样式。
    ```jsx
    const CustomDropdownIndicator = (props) => (
      <components.DropdownIndicator {...props} />
    );

    <Select
      components={{ DropdownIndicator: CustomDropdownIndicator }}
    />
30. ValueContainer:自定义选中值的容器样式和行为。
    ```jsx
    const CustomValueContainer = (props) => (
      <components.ValueContainer {...props} />
    );

    <Select
      components={{ ValueContainer: CustomValueContainer }}
    />
    ```

31. GroupHeading:自定义选项分组的标题样式。
    ```jsx
    const CustomGroupHeading = (props) => (
      <components.GroupHeading {...props} />
    );

    <Select
      components={{ GroupHeading: CustomGroupHeading }}
    />
    ```

32. IndicatorSeparator:自定义指示器之间的分隔符样式。
    ```jsx
    const CustomIndicatorSeparator = (props) => (
      <components.IndicatorSeparator {...props} />
    );

    <Select
      components={{ IndicatorSeparator: CustomIndicatorSeparator }}
    />





{ type: "searchSelect", placeholder: "签约机构", valueName: 'signOrganId', optionName: "label", searchItemName: "label", optionId: "key", searchApi:commonService.orgPageList({}).then(res=>{ const {retData}=res retData.map(item=>{ return {key: item.id, label: item.organName, value: item.id,} }) }) }, 分析一下此段代码的报错 汉语解释 ,并修改searchApi中的代码,index.jsx:55 Uncaught TypeError: item.searchApi is not a function at searchQuery (index.jsx:55:1) at onFocus (index.jsx:129:1) at onContainerFocus (BaseSelect.js:326:1) at HTMLUnknownElement.callCallback (react-dom.development.js:188:1) at Object.invokeGuardedCallbackDev (react-dom.development.js:237:1) at invokeGuardedCallback (react-dom.development.js:292:1) at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:306:1) at executeDispatch (react-dom.development.js:389:1) at executeDispatchesInOrder (react-dom.development.js:414:1) at executeDispatchesAndRelease (react-dom.development.js:3278:1) at executeDispatchesAndReleaseTopLevel (react-dom.development.js:3287:1) at forEachAccumulated (react-dom.development.js:3259:1) at runEventsInBatch (react-dom.development.js:3304:1) at runExtractedPluginEventsInBatch (react-dom.development.js:3514:1) at handleTopLevel (react-dom.development.js:3558:1) at batchedEventUpdates$1 (react-dom.development.js:21871:1) at batchedEventUpdates (react-dom.development.js:795:1) at dispatchEventForLegacyPluginEventSystem (react-dom.development.js:3568:1) at attemptToDispatchEvent (react-dom.development.js:4267:1) at dispatchEvent (react-dom.development.js:4189:1) at unstable_runWithPriority (scheduler.development.js:653:1) at runWithPriority$1 (react-dom.development.js:11039:1) at discreteUpdates$1 (react-dom.development.js:21887:1) at discreteUpdates (react-dom.development.js:806:1) at dispatchDiscreteEvent (react-dom.development.js:4168:1)
07-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值