运行 与 rails 一起使用 React Datepicker 遇到问题
Running into problems using React Datepicker with rails
我正在使用这个日期选择器插件进行反应:https://github.com/Hacker0x01/react-datepicker
我不断收到以下错误:
未捕获的类型错误:this.props.moment 不是 react-datepicker.min.js 中的函数。
我刚刚复制了示例代码,我可以看到输入字段,但是每当我点击它来渲染日历时,它总是出现上面的错误。有人知道过去遇到过这个问题吗?
刚解决,是application.js中的"moment"js文件不需要的问题。如果您使用 bundler 安装此插件,请确保将以下内容添加到 gemfile 中:
source "https://rails-assets.org" do
gem 'rails-assets-react-date-picker'
gem "rails-assets-moment"
end
然后在 application.js 中按以下顺序要求两者:
//= require "moment"
//= require "react-date-picker"
我正在使用这个日期选择器插件进行反应:https://github.com/Hacker0x01/react-datepicker
我不断收到以下错误: 未捕获的类型错误:this.props.moment 不是 react-datepicker.min.js 中的函数。
我刚刚复制了示例代码,我可以看到输入字段,但是每当我点击它来渲染日历时,它总是出现上面的错误。有人知道过去遇到过这个问题吗?
刚解决,是application.js中的"moment"js文件不需要的问题。如果您使用 bundler 安装此插件,请确保将以下内容添加到 gemfile 中:
source "https://rails-assets.org" do
gem 'rails-assets-react-date-picker'
gem "rails-assets-moment"
end
然后在 application.js 中按以下顺序要求两者:
//= require "moment"
//= require "react-date-picker"