reactjs - TypeError: __webpack_require__.i(...) 不是 React-Select 中的函数
问题描述
我正在使用react-select插件从下拉列表中进行多项选择。
对于安装我已经完成
npm install react-select --save
其中安装了最新版本 3.0.4 的 react-select 插件
我的代码是
import React, { Component } from 'react';
import Select from 'react-select';
import urls from '../../../urls.json';
const options = [
{ value: 'chocolate', label: 'Chocolate' },
{ value: 'strawberry', label: 'Strawberry' },
{ value: 'vanilla', label: 'Vanilla' },
];
class Reports extends Component {
constructor(props) {
super(props);
this.state = {
selectedOption: null,
};
}
handleChange = selectedOption => {
this.setState({ selectedOption });
console.log(`Option selected:`, selectedOption);
};
componentDidMount() { }
render() {
return (
<div>
<div className="row">
<div className="col-md-12">
<h2>Reports</h2>
<hr className="title-separator" />
<Select
value={this.state.selectedOption}
onChange={this.handleChange}
options={options}
/>
</div>
</div>
</div >
)
}
}
export default Reports;
请帮忙!
解决方案
您使用的版本react-select
与您的react
. react-select
您可以通过执行以下操作降级以使用 v2:
npm install react-select@2.4.4
有关升级的更多详细信息,请参阅v3 升级指南。
推荐阅读
- typescript - 为什么打字稿中允许这样做?
- oracle - 我如何解决外键中的 ORACLE 问题
- openshift - 为什么某些 OpenShift 命令会特殊处理 PersistentVolumeClaims
- drupal-8 - Drupal 8 - hook_mail 没有被调用
- java - Java加速进程/线程
- rule-engine - 规则验证问题 - 保存时有效,加载时无效
- tableau-api - 在 Tableau 中合并列名
- python - 使密码/哈希验证算法更高效
- javascript - script16389:未指定的错误。填充物(1,10884)
- javascript - 在Javascript中返回未定义的函数