gpt4 book ai didi

javascript - 访问 react-select 中的内部输入元素

转载 作者:行者123 更新时间:2023-12-04 10:37:05 26 4
gpt4 key购买 nike

那里有一个名为 farsitype.js 的脚本,我想将它与 react-select 组件一起使用,但无法直接访问内部输入字段以向其添加属性。有什么方法可以将属性添加到 react-select 中的内部输入字段?

最佳答案

如果你在谈论这个react-select图书馆。您可以像这样自定义 Input 组件:

import React from 'react';
import Select, { components } from 'react-select';
import { typeOptions } from '../data';

const Input = props => {
// add attribues to the component below
return <components.Input {...props} />;
};

export default () => (
<Select
components={{ Input }}
options={typeOptions}
/>
);

关于javascript - 访问 react-select 中的内部输入元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60124129/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com