【问题标题】:Why does my laravel project display @extends, @yield and @section as plain text?为什么我的 laravel 项目将@extends、@yield 和@section 显示为纯文本?
【发布时间】:2019-11-06 10:04:14
【问题描述】:

我创建了一个新的 laravel 项目,它将 @extends、@yield 和 @section 显示为纯文本,我在 laragon 上安装了 php,一切正常。

这是我的主布局文件 master.blade.php

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>@yield('title')</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css">
    <link rel="stylesheet" href="{{ URL::to('src/css/app.css') }}">

    @yield('styles')
</head>
<body>
@include('partials.header')
<div class="container">
    @yield('content')
</div>

<script   src="https://code.jquery.com/jquery-1.12.3.min.js"   integrity="sha256-aaODHAgvwQW1bFOGXMeX+pC4PZIPsvn2h1sArYOhgXQ="   crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
@yield('scripts')
</body>
</html>

这是 index.blade.php,它是项目的主要部分

@extends ('layouts.master')

@section('title')
    Laravel Shopping Cart
@endsection

它只显示like this

我不明白为什么它们在我的 api.php 中也不起作用

已添加此代码以使其工作

Route::get('/', function () {
    return view('shop.index');
});

【问题讨论】:

  • 普通的 PHP 代码是什么样子的。例如&lt;?php echo 'PHP code'; ?&gt; ?
  • @apokryfos 就像普通代码一样,!like this
  • 检查文件夹/文件权限
  • 我已完全控制该 www/ 文件夹中的所有文件

标签: php laravel layout laravel-blade


【解决方案1】:

删除@extends ('layouts.master')中的空格。

【讨论】:

  • 那没有帮助
【解决方案2】:

你错了几行, 删除此代码上的空格

@extends('layouts.master')

并确保您的文件夹位置资源->查看->商店->index.blade.php

【讨论】:

    【解决方案3】:

    我没有在我的项目文件夹上运行php artisan serve,这是导致问题的原因,不过谢谢大家!!

    【讨论】:

      猜你喜欢
      • 2021-03-29
      • 2017-05-16
      • 2011-04-03
      • 2019-01-15
      • 2017-11-18
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      相关资源
      最近更新 更多