我尝试将DataPicker添加到我的组件中:
import React, { Component } from 'react';
import DatePicker from 'react-date-picker';
class TestPage extends Component {
constructor(props) {
super(props);
this.state = {
date: new Date()
};
this.handleOnChange = this.handleOnChange.bind(this);
}
handleOnChange(date) {
this.setState(date);
}
render() {
return (
<div>
<DatePicker
onChange={this.onChange}
value={this.state.date}
/>
</div>
);
}
}
我这样安装react-data-picker:
npm i react-date-picker@6.7.0
但是在此之后,我在控制台中出现了错误。
Nodemon :
module.js:549 犯错 ^
错误:找不到模块“ react-calendar / dist / shared / locales”
Webpack-dev-server :
./~/react-date-picker/dist/shared/locales.js模块中的错误 找到:错误:无法解析模块 “ react-calendar / dist / shared / locales”位于 / home / jack /Документы/ myapp / frontend / node_modules / react-date-picker / dist / shared @ ./~/react-date-picker/dist/shared/locales.js 7:15-60
我该如何解决?还是我应该为我的应用程序使用其他数据选择器?