LoginSignup
0
0

More than 1 year has passed since last update.

@includeについて

Posted at

@include とは

bladeの共通箇所を子ファイルとして作成し、親ファイルで呼び出す時に@includeが使える

使い方

親ファイルresorces/views/parent.blade.phpの中で、子ファイルresorces/views/child.blade.phpを読み込む場合

親ファイル parent.blade.php 内での記述

parent.blade.php
@include('child')

とすれば読み込める。

変数も渡せる

また、親ファイルで持っている変数を子ファイルに渡すこともできる。
例えば変数$dataを渡したい時は、、

parent.blade.php
@include('child', ['data' => $data])

とすれば子ファイルでも$dataを使用することが可能。

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