简体   繁体   English

我应该如何更改路线以使其通过“。”号找到路线?

[英]how should i change a route to make it find routes by dotes “.”?

I'm doing a project that the tutorial that I'm learning from, has not the same LARAVEL version as the mine. 我正在做一个项目,该项目是我正在学习的教程,其版本与我的LARAVEL版本不同。 so it keeps routing the controllers with dots but doesn't make any changes to the routing page codes. 因此它始终用点来路由控制器,但不对路由页面代码进行任何更改。 like setting or changing the rout name or something like that and for that version it worked fine. 例如设置或更改溃败名称或类似名称,对于该版本,它可以正常工作。 but in my project, server can't recognize that kind of routing. 但是在我的项目中,服务器无法识别这种路由。 how should i change the routes to work correctly? 我应该如何更改路线才能正常工作?

i know for those kind of routes that we add them we can set a name for them to find the route correctly but I need to set the /home route in a way that will work fine but it doesn't matter where do i add the dot in the name of route, .home or home. 我知道对于我们添加它们的那些路由,我们可以为它们设置一个名称以正确找到路由,但是我需要以一种可以正常工作的方式设置/home路由,但是我在哪里添加都没关系路线名称( .homehome)中的点。 , it won't work! ,将无法正常工作!

here is my web.php code: Route::get('/home', 'HomeController@index')->name('home'); 这是我的web.php代码: Route::get('/home', 'HomeController@index')->name('home');

and my controller : 和我的控制器

public function index()
    {
        return View('index.index');
    }

localhost:8000/home works fine but i need to fix localhost:8000 routing to be recogniz 本地主机:8000 / home工作正常,但我需要修复本地主机:8000路由才能识别

it's unclear what you're asking. 不清楚你在问什么。

You've made an url for /home which is named home . 您已经为/home了一个名为home的URL。 This means that in your blade templates, you can call 这意味着您可以在刀片模板中调用

<a href="{{ route('home') }}">

The dot can be used as a separation symbol, Naming the route home.index usually means: home controller, index method. 点可以用作分隔符号,命名路线home.index通常意味着:home控制器,索引方法。 It can be whatever you like though. 可以随便你。

So you likely want to change the route name to ->name('home.index') 因此,您可能希望将路由名称更改为->name('home.index')

You could then access that using route('home.index') 然后,您可以使用route('home.index')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我应该如何在 Laravel 中构建我的路由和控制器? - How should I structure my routes and controllers in Laravel? 如何在Rails 3中创建自定义控制器操作的路由? - How do I make a route to a custom controller action in Rails 3? 没有路由匹配{:controller =&gt;“ queue_videos”},即使我使用了rake路由中的路径 - No route matches {:controller=>“queue_videos”} even I used the path from rake routes 如何在Codeigniter中更改课堂路线 - How to change route in class in codeigniter Laravel路由动态路由控制器到刀片模板 - Laravel route dynamic routes controller to blade template “没有路线匹配”错误,但耙路找到了 - “No route matches” error but rake routes finds it 在Angular中,如何从控制器内部找到“调用”控制器的路径? - In Angular, how to find the route that “called” the controller from inside the controller? 如何在Rails 5中建立动态路线? - How do I build a dynamic route in Rails 5? 我的表单需要额外的数据,我应该在哪里放置我的路由和控制器方法来获取它? - My form requires additional data, where should I put my routes and controller methods to get it? 我应该在 controller 或服务中的 spring 应用程序中在哪里进行 API 调用? - Where should I make API calls in a spring application, in the controller or service?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM