php 如何将路线返回到 Laravel 中的视图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26086710/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to return routes to views in laravel
提问by Cozzbie
I just tried loading a view using a route like so:
我只是尝试使用如下路线加载视图:
route.php
Route::get("/page", function(){
return View::make("dir.page");
});
controller.php
View::make("/page");
...and an error was thrown. So my question is:
...并抛出一个错误。所以我的问题是:
Is it possible to load a route via a view and if its possible then how?
是否可以通过视图加载路线,如果可能,那么如何加载?
Thanks.
谢谢。
回答by Danny
Your should return
your View.
你应该return
你的观点。
So this will work fine:
所以这会正常工作:
Route::get("/page", function(){
return View::make("dir.page");
});
回答by Neabfi
In Laravel 5.5 you can now do:
在 Laravel 5.5 中,您现在可以执行以下操作:
Route::view('/page', 'dir.page');
回答by Aruna Perera
In laravel 5.8 I had to use this.
在 laravel 5.8 中我不得不使用它。
Route::get("/page", function(){
return \View::make("dir.page");
});