我正在尝试使用React-Select进行设置。它在标准的React项目中运行良好,但在TypeScript React项目中(均使用带有webpack的Create-React-App),却无法正常工作。
在我的TypeScript项目中,它显示“Select”未被导出。我可以选择“SelectBase”,但它不能按预期工作。
已执行的步骤: 我通过npm安装了react-select和@types/react-select。
在我的组件中,当尝试从“react-select”中导入Select时,我会在“Select”上看到TypeScript的下划线,并出现错误(请参见下文)。
使用的配置:
npm install --save react-select
npm install --save-dev @types/react-select
import Select from 'react-select'; (errors here)
错误:
Module '"../../...project.../node_modules/@types/react-select"' has no exported member 'Select'. ts(2305)
Module '"c:/...project.../node_modules/@types/react-select/index"' has no exported member 'Select'. ts(2305)
文档只展示了使用yarn进行安装,但我想使用npm也可以。 我需要进行不同的配置吗? 谢谢
* as
结构导入它:import * as Select from 'react-select';
- Richard