php - 试图在被覆盖的部分刀片中获取非对象的属性“名称”
问题描述
我的 layoutblade.php 中有这个:
@section('content')
<h2>Title of the site</h2>
<p>other content</p>
{{ $myVariable }}
@show
我的 test.blade.php 中有这个
@extends('layout')
@section('content')
other content
@endsection
但是,在这个视图中,我有未定义的变量,它覆盖了视图,而不是变量,帮助我。
解决方案
//layout
@yield('content')
//test.blade.php
@extends('layout')
@section('content')
{{ $myVariable }}
other content
@endsection
那么你{{ $myVariable }}
应该像这样从你的控制器输出:
$data['myVariable']='';
return view('test',$data)