web.php
Route::group(['middleware' => ['auth','Admin']], function () {
...
Route::get('/foo/fp',['uses' => 'ProgramReportController@getFp', 'as' => 'foo.getfp']);
});
ProgramReportController.php
class ProgramReportController extends Controller
{
...
public function getFp() {
$data = Fpchart::select('*')->get()->toArray();
$data = json_encode($data);
return view('foo.fp',compact('data'));
}
}
foo\fp.php
@extends('layouts.foo')
@section('content')
<script>
var data = {!!$data!!};
console.log(data);
</script>
@endsection
layouts\foo.blade.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Foo</title>
<!-- Bootstrap core CSS -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" ></script>
<script src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
<script src="{{asset('js/custom.js')}}"></script>
<link href="{{asset('css/styles.css')}}" rel="stylesheet">
</head>
<body>
@yield('content')
<footer class="footer">
<div class="container">
<span class="text-muted">
<strong style="font-size: 78%;">
<a href="#">ABOUT</a>
<a href="#">PRIVACY</a>
<a href="#">TERMS</a>
<div class="pull-right">© 2020 FOO</div>
</strong>
</span>
</div>
</footer>
</body>
</html>
我只得到一个白色页面,当我转到localhost:8000/foo/fp时,布局没有加载。我在页面上看到的就是这个..。
@extends('layouts.ched') @section('content') @endsection
在我的控制台中,我得到了这个错误:
Uncaught SyntaxError: Unexpected token '!' on line 4 in fp.php
我试了所有的方法来清理我的缓存
php artisan optimize
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear
但无济于事,什么也没发生。当我转到管理中间件下的其他页面时,页面加载正常,除了这个,所以我认为这可能是一个缓存问题,但我已经尝试了所有方法。
发布于 2020-10-15 07:29:52
您只能在.blade.php
文件中使用刀片指令:
将fp.php
重命名为fp.blade.php
,这样就可以了
https://stackoverflow.com/questions/64366424
复制相似问题