2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Laravel で flatpickr を使ってカレンダーでの月選択

Last updated at Posted at 2019-10-28

普通にflatpickrをインストールして、日付を選択するだけなら容易なのですが、
flatpickrの公式から月のみ表示して、月を選択できるようになったのでやってみます。

ミスがありましたらご指摘お願いいたします。

動作

公式より
こちらから確認できます

インストール

CDN版

//flatpickrのCDN
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
//flatpickrの月選択プラグイン
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr@latest/dist/plugins/monthSelect/style.css">
<script src="https://cdn.jsdelivr.net/npm/flatpickr@latest/dist/plugins/monthSelect/index.js"></script>

npm

npm
npm i flatpickr --save
resources/js/app.js
import flatpickr from "flatpickr";
import monthSelectPlugin from 'flatpickr/dist/plugins/monthSelect/index';

resources/sass/app.js
@import "../../node_modules/flatpickr/dist/themes/airbnb.css";

@import "../../node_modules/flatpickr/dist/plugins/monthSelect/style.css";

使用

インストールしたら使用できるようになるので、使ってみます

resources/js/app.js

flatpickr(".js-calendar", {
        plugins: [
            new monthSelectPlugin({})
        ],
      })

コンパイルして表示を確認します

npm run dev

日本語化しているとこのような表示になります。
SC000006.JPG

参考にしたサイト

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?