为什么找不到视图 [layouts.main]

huangapple go评论87阅读模式
英文:

Why View [layouts.main] not found

问题

查看 [layouts.main] 未找到。

为什么即使位置正确,也无法读取?

picture_home.blade.php

标题:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <h1>kontol</h1>
    <div class="konteng">
        @yield('container')
    </div>
</body>
</html>
英文:

View [layouts.main] not found.

why is this even though the place is correct why can't it be read?

picture_home.blade.php

the Header :

&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
    &lt;meta charset=&quot;UTF-8&quot;&gt;
    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;ie=edge&quot;&gt;
    &lt;title&gt;Document&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;h1&gt;kontol&lt;/h1&gt;
    &lt;div class=&quot;konteng&quot;&gt;
        @yield(&#39;container&#39;)
    &lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;

答案1

得分: 3

您的布局或Blade文件应该位于resources/views文件夹中。将您的文件从resources/layouts/main.blade.php移动到resources/views/layouts/main.blade.php

然后,我假设您的主页使用beranda.blade.php,您可以像这样使用布局:

@extends('layouts.main')

@section('container')
    {{-- 在这里添加代码 --}}
@endsection
英文:

Your layouts or blade files should be in resources/views folder. Move your file from resources/layouts/main.blade.php to resources/views/layouts/main.blade.php.

Then I assume your homepage using beranda.blade.php, you can use the layout like this :

@extends(&#39;layouts.main&#39;)

@section(&#39;container&#39;)
    {{-- code here --}}
@endsection

huangapple
  • 本文由 发表于 2023年6月13日 09:10:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76461133.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定