简体   繁体   English

从views文件夹中的文件导航到laravel中views文件夹中的另一个文件

[英]Navigate from a file in views folder to another file in views folder in laravel

I am new to laravel and struggling with the basics.Could anyone help? 我是laravel的新手,并且在基础方面苦苦挣扎,有人可以帮忙吗?

I want to navigate from index.blade.php to dashbaord.blade.php in laravel. 我想从index.blade.php中的dashbaord.blade.php导航到dashbaord.blade.php。 Both index.blade.php and dashboard.blade.php are located like this in the resources folder index.blade.phpdashboard.blade.php都位于资源文件夹中,就像这样

resources/cutups/
       index.blade.php
       dashboard.blade.php

Tried using 尝试使用

href="{{ route('cutups.dashboard') }}">Create

but result in an error 但导致错误

By Laravel documentation all the view files must be in resources/views . 通过Laravel文档,所有视图文件都必须位于resources/views Of course you can use more folders under that folder. 当然,您可以在该文件夹下使用更多文件夹。 For example 例如

resources/views/cutups/
     index.blade.php
     dashboard.blade.php

When you create a new page/view , to access it you actually need to do 2 things: 创建新page/view ,实际上需要执行以下两项操作:

1. create that page in folder `resources/views/*`
2. create a route in folder `routes/web.php`

and then you can open it through the browser. 然后您可以通过浏览器将其打开。

For your example to open this link <a href="{{ route('cutups.dashboard') }}">Create</a> 以您的示例打开此链接<a href="{{ route('cutups.dashboard') }}">Create</a>

  1. Create that view (you already created it). 创建该视图(您已经创建了它)。

  2. Create this route in web.php file 在web.php文件中创建此路由

     Route::get('/cutups/dashboard', function () { return view('cutups/dashboard'); }); 

and now you can open it with a click on your link. 现在您可以单击链接打开它。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM