php - Laravel - 在子文件夹中返回 View

标签 php laravel routes

我有以下几行:

Route::get('/dashboard', function () {
    return view('main.index');
});

但我的 View 位于 main/sub/index.blade.php

我试过了
Route::get('/dashboard', function () {
        return view('main.sub.index');
    });


 Route::get('/dashboard', function () {
        return view('main/sub.index');
    });

没用。

最佳答案

将 View 移至:

resources/views/main/sub/index.blade.php

然后此代码将起作用:
Route::get('/dashboard', function () {
    return view('main.sub.index');
});

来自 the docs :

Views are stored in the resources/views directory. Since this view is stored at resources/views/greeting.blade.php, we may return it using the global view helper like so:


return view('greeting', ['name' => 'James']);

关于php - Laravel - 在子文件夹中返回 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48769328/

相关文章:

javascript - 将输入值检索到 formData 对象中

angularjs - Laravel 如何忽略除某些前缀之外的所有内容?

node.js - 从另一个人那里调用快速路线是不好的做法吗?

php - 升级具有良好打印支持的 VB6 应用程序的建议

php - 如何在不覆盖任何值的情况下合并两个集合

php - 只获取倒数第二条记录 - mysql-query

apache - 在公共(public)根目录的子目录中部署 Laravel 5 项目

dynamic - 如何在*Application_Start之后动态添加OData Web Api路由?

php - 从 Laravel 内部进行异步 AJAX 调用

php - BigINT 和 VarChar 的区别,长度 16 个字符