你也可以通过在路由中使用全局辅助函数 view 来返回 Blade 视图:Route::get('blade', function () { return view('child');});Components & SlotsComponents 和 slots 类似于布局中的 @section,但其使用方式更容易使人理解。首先,假设我们有一个能在整个应用程序中被重复使用的「警告」组件:...
Route::get('logout', 'IndexController@logout'); }); // 后台登录路由 Route::group(['middleware' => 'web'], function(){ Route::get('admin/login', 'Admin\IndexController@login'); });这是后台Admin 目录下 Index 控制器的代码:1
Route::get('greeting',function(){ returnview('welcome',['name'=>'Samantha']); }); 你可以像这样显示name变量的内容: Hello,{{$name}}. 当然也不是说一定只能显示传递至视图的变量内容。你也可以显示 PHP 函数的结果。事实上,你可以在 Blade 中显示任意的 PHP 代码: ...
Route::get('blade',function(){returnview('child');}); 组件& Slots# 组件和 slots 能提供类似于区块和布局的好处;不过,一些人可能发现组件和 slots 更容易理解。首先,让我们假设一个会在我们应用中重复使用的「警告」组件: <!-- /resources/views/alert.blade.php -->{{$slot}} {{ $slot }}变量将...
Blade 视图可以像原生 PHP 视图一样使用全局帮助函数 view 来返回渲染后的内容: Route::get('blade', function () { return view('child'); }); 显示数据 你可以使用花括号 { 来在视图中显示传递到视图中的变量,例如,你定义了下面的路由: Route::get('greeting', function () { return view('welcome'...
Route::get('blade', function () { returnview('child'); }); 6.数据显示: Route::get('greeting', function () { returnview('welcome', ['name'=>'Samantha']); }); 模板中: Hello, {{ $name }}. 在模板中输出函数 The current UNIX timestampis{{ time() }}. ...
Current Route AccessThe current route is now accessed via Route::current() instead of Route::getCurrentRoute().Composer UpdateOnce you have completed the changes above, you can run the composer update function to update your core application files! If you receive class load errors, try running...
Route::get('greeting', function () { return view('welcome', ['name' => 'Samantha']); }); 我们可以这样显示name变量的内容:Hello, {{ $name }}. Blade {{ }}语句通过PHP的htmlspecialchars功能自动发送,以防止XSS攻击。不仅限于显示传递给视图的变量的内容。也可以在视图中调用任何的PHP函数,并...
Route::get('blade', function () { return view('child'); }); 这样在浏览器中访问 http://blog.test/blade,就可以看到页面显示如下: 现在页面还很粗糙,没有任何样式,后面学习前端组件后可以回来完善。 组件& 插槽 组件和插槽给内容片段(section)和布局(layout)带来了方便,不过,有些人可能会发现组件和插...
Route::get('greeting',function(){returnview('welcome',['name'=>''Samantha']);}) 下面就可以使用name变量显示内容了: Hello! {{ $name }} {{ }}是 Blade 视图的打印语句,当然,打印语句里不限制只能打印变量内容,也可以使用 PHP 函数。实际上,打印语句这里可以使用任何 PHP 代码: ...