1
1

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.

Laravel 特定の子ビューでのみ使用するJSファイルのインポート方法

Last updated at Posted at 2022-03-28

目的

Untitled Diagram.png
共通レイアウト使用時に、子ビューの1つであるfuga.blade.phpのみでfuga.jsを読み込む。

やり方

1.親ビューにスタックを定義する

layout.blade.php
<head>
  @stack('scripts')
<head>

2.子ビューで親ビューのスタックにプッシュする

fuga.blade.php
@push('scripts')
  <script src="{{ mix('js/fuga.js') }}" defer></script>
@endpush

参考

1
1
1

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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?