質問編集履歴
2
誤字を直しました
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#### LaravelのBladeについて
|
|
2
2
|
[公式のドキュメント](https://readouble.com/laravel/5.5/ja/blade.html#components-and-slots)を読み、実際に動作させながら学んでいます
|
|
3
|
-
|
|
3
|
+
Laravel自体は起動していて[テンプレートの継承](https://readouble.com/laravel/5.5/ja/blade.html#template-inheritance)は問題なく動作・理解できました
|
|
4
4
|
|
|
5
5
|
コンポーネントとスロットについてalert.blade.phpはこの通り作成しました
|
|
6
6
|
|
1
タイトルを変更し初心者マークをつけました、現在のコードを記述しました
title
CHANGED
|
@@ -1,1 +1,1 @@
|
|
|
1
|
-
LaravelのBladeのSlot&Componentの使い方がわかりません
|
|
1
|
+
LaravelのBladeのSlot&Componentの使い方がわかりません
|
body
CHANGED
|
@@ -3,10 +3,30 @@
|
|
|
3
3
|
Larabel自体は起動していて[テンプレートの継承](https://readouble.com/laravel/5.5/ja/blade.html#template-inheritance)は問題なく動作・理解できました
|
|
4
4
|
|
|
5
5
|
コンポーネントとスロットについてalert.blade.phpはこの通り作成しました
|
|
6
|
+
|
|
7
|
+
```php
|
|
8
|
+
<!-- /resources/views/alert.blade.php -->
|
|
9
|
+
|
|
10
|
+
<div class="alert alert-danger">
|
|
11
|
+
{{ $slot }}
|
|
12
|
+
</div>
|
|
13
|
+
```
|
|
14
|
+
|
|
6
15
|
@componentの部分はどこに記述すれば良いのでしょうか
|
|
7
16
|
同ファイルに記述したり、子のbladeファイルを作成して継承してみたりしましたがエラーになります
|
|
8
|
-
エラーを調べた限り変数が定義されていないという内容でした
|
|
9
17
|
|
|
18
|
+
```php
|
|
19
|
+
<!-- /resources/views/call.blade.php -->
|
|
20
|
+
@extends('alert')
|
|
21
|
+
|
|
22
|
+
@component('alert')
|
|
23
|
+
<strong>Whoops!</strong> Something went wrong!
|
|
24
|
+
@endcomponent
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
|
|
10
28
|
エラーメッセージ
|
|
11
29
|
`Facade\Ignition\Exceptions\ViewException`
|
|
12
|
-
`Undefined variable: slot (View: /Users/hoge/projects/lara-test/resources/views/alert.blade.php)`
|
|
30
|
+
`Undefined variable: slot (View: /Users/hoge/projects/lara-test/resources/views/alert.blade.php)`
|
|
31
|
+
|
|
32
|
+
エラーを調べた限り変数が定義されていないという内容でした
|