我对flatpickr的日历有疑问。它不再显示日历,我也不知道为什么...我已经测试了另一篇文章的解决方案:Calendar is not displaying correctly using flatpickr,但是它不起作用。
我可以手动更改日期,但是当我单击日期按钮时,就没有日历了。
谢谢您的帮助 !!

我的代码:

flatpickr.js

import flatpickr from "flatpickr"
import "flatpickr/dist/flatpickr.min.css"

flatpickr(".datepicker", {
  allowInput: true,
  dateFormat: "d.m.Y",
  mode: "single",
  maxDate: "today",
  locale: {
    firstDayOfWeek: 1,
    weekdays: {
      shorthand: ["dim", "lun", "mar", "mer", "jeu", "ven", "sam"],
      longhand: ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"],
    },
    months: {
      shorthand: ["janv","févr", "mars", "avr", "mai", "juin", "juil", "août", "sept", "oct", "nov", "déc",],
      longhand: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
    },
  },
  disableMobile: "true",
})


application.html.erb

<title>Collecte des avis clients dans le restaurant, solution digital de rétention et fidélisation clients</title>
    <%= csrf_meta_tags %>
    <%= action_cable_meta_tag %>
    <%= stylesheet_link_tag 'application', media: 'all' %>
    <%= stylesheet_pack_tag 'application', media: 'all' %>
    <%= favicon_link_tag asset_path('flavicon.png') %>
    <!-- Uncomment if you import CSS in app/javascript/packs/application.js -->
    <script src="https://unpkg.com/[email protected]/dist/aos.js" data-turbolinks-eval=false></script>

  </head>

  <body>
    <%= render "/shared/flashes" %>
    <%= yield %>
    <%= javascript_include_tag 'application' %>
    <%= javascript_pack_tag 'application' %>
    <script>AOS.init();</script>


application.js:

//= require_tree .
//= require jquery


day.html.erb:

<div>
 <%= form_tag day_restaurant_path(@restaurant), method: :get do %>
 <%= text_field_tag :date, params[:search_date], class: "datepicker deco-flatpickr", value: @search_date.strftime("%d-%m-%Y") %>
 <% end %>
</div>

最佳答案

我们终于找到了为什么flatpickr不再起作用的原因:因为我们将webpacker版本3.5.5升级到了4.0.1。当我们降级版本或Webpacker时,它又可以工作了!谢谢您的帮助 !!

09-28 00:50