0
0

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 1 year has passed since last update.

bootstrap-datepickerでCDNを使わない。。

Posted at

日付の入力にbootstrapのdatepickerを使用するため、
backend.blade.phpへCDNを記述していた。

<script src="https://cdn.jsdelivr.net/npm/bootstrap-datepicker@1.9.0/dist/js/bootstrap-datepicker.min.js"
        integrity="sha256-bqVeqGdJ7h/lYPq6xrPv/YGzMEb6dNxlfiTUHSgRCp8=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-datepicker@1.9.0/dist/css/bootstrap-datepicker3.css"
      integrity="sha256-AghQEDQh6JXTN1iI/BatwbIHpJRKQcg2lay7DE5U/RQ=" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap-datepicker@1.9.0/dist/locales/bootstrap-datepicker.ja.min.js"
        integrity="sha256-IX182a23hiQE65+kYOND1ZIX2Vpl0cHb96g9nJqqqW0=" crossorigin="anonymous"></script>

本題 : CDNなしでdatepickerを使えるようにしよう!

参考資料↓

1. bootstrap-datepickerをダウンロードする

下記サイトから「Download x.x.x」ボタンを押してダウンロードを実行する

2. 各ファイルを設置する

各ファイルを対応するフォルダ内へ設置します。
(下記の設置場所は、それぞれご自分の環境に合うように設置してください。)

bootstrap-datepicker.min.js (jsフォルダの中にある本体)
bootstrap-datepicker.ja.min.js (localesフォルダにある日本語化ファイル)
bootstrap-datepicker3.css (cssフォルダの中にあるcss)

3.仕上げ

コマンドを入力し反映させます

$ npm run dev

蛇足 : 私の場合

resource/jsへbootstrap-datepicker.min.jsbootstrap-datepicker.ja.min.jsを設置。
resource/ja/app.jsへ下記コードを追加し、ファイルを読み込ませる。

require('./bootstrap-datepicker.min');
require('./bootstrap-datepicker.ja.min');

resource/scssへbootstrap-datepicker3.cssを設置。
resource/scss/app.scssへ下記コードを追加し、ファイルを読み込ませる。

@import 'bootstrap-datepicker3';
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?