javascript React-Strap 的日期选择器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47271566/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 07:17:01  来源:igfitidea点击:

Datepicker for React-Strap

javascriptreactjsreact-bootstrapbootstrap-datepicker

提问by Nyxynyx

I am using react-strapnpm package to use Bootstrap 4 components in my React app.

我正在使用react-strapnpm 包在我的 React 应用程序中使用 Bootstrap 4 组件。

When I try to add the datepicker react-bootstrap-date-picker

当我尝试添加日期选择器时 react-bootstrap-date-picker

npm install --save react-bootstrap-date-picker

then try to use it in my component:

然后尝试在我的组件中使用它:

var DatePicker = require("react-bootstrap-date-picker");

I get the error

我收到错误

Error in ./~/react-bootstrap-date-picker/lib/index.js

Module not found: 'react-bootstrap/lib/Button' in C:\Users\y\Desktop\Code\test\node_modules\react-bootstrap-date-picker\lib

@ ./~/react-bootstrap-date-picker/lib/index.js 15:14-51

./~/react-bootstrap-date-picker/lib/index.js 中的错误

未找到模块:C:\Users\y\Desktop\Code\test\node_modules\react-bootstrap-date-picker\lib 中的“react-bootstrap/lib/Button”

@ ./~/react-bootstrap-date-picker/lib/index.js 15:14-51

Is this because react-bootstrap-date-pickeris not compatible with react-strap? In this case, which npm packages should I install for bootstrap 4 components so that the datepicker module can work?

这是因为react-bootstrap-date-picker与 不兼容react-strap吗?在这种情况下,我应该为 bootstrap 4 组件安装哪些 npm 包,以便 datepicker 模块可以工作?

回答by shuning

react-bootstrap-date-picker is using react-bootstrap, react-bootstrap depends on bootstrap3. reactstrap is for bootstrap4 That is why it doesnt work.

react-bootstrap-date-picker 使用的是 react-bootstrap,react-bootstrap 依赖于 bootstrap3。reactstrap 用于 bootstrap4 这就是它不起作用的原因。

You can use react-widgets DateTimePickerinstead.

您可以改用react-widgets DateTimePicker

回答by Afialapis

You have now available reactstrap-date-picker, which is heavily based on react-bootstrap-date-picker, but ready for the reactstrapworld.

您现在可以使用reactstrap-date-picker,它主要基于react-bootstrap-date-picker,但已准备好面向reactstrap世界。

Disclaimer: I'm the author of the library.

免责声明:我是图书馆的作者。

Although still in first 0.* versions, I'm using it successfully on my projects and, as soon as I receive feedback enough, it'll be 1.0 and considered production-ready.

虽然仍然是第一个 0.* 版本,但我已经在我的项目中成功地使用了它,一旦我收到足够的反馈,它就会成为 1.0 并被认为可以生产。