Laravel将所有/ admin / *发送到特定视图

问题描述 投票:0回答:1

我正在开发一个网站,该网站具有简单的登陆,新闻和联系人作为前端(使用php足够足够了。.vuejs可能会过分...),而vue js作为后端。尝试将所有请求从/ admin / *发送到view('admin'),这是我能想到的最好的方法:

Route::prefix('admin')->group(function () {
   Route::any('{query}', function() {
       return view('admin');
   })->where('query', '.*');
});

在route:list中,似乎列出的很好,并且(希望)它应该可以工作。但是我得到的是404-未找到(我希望标准的laravel错误页面应该由vuejs处理,而不是laravel,因为它在后端。在Apache日志中根本没有记录错误,在laravel日志中也没有记录。在哪里我做错了吗?

// 该项目基本上是在流明中完成的,但是流明有相同的问题。由于laravel是流明之父,因此与laravel进行了尝试,但似乎有相同的反应。我想念什么吗?

api vuejs2 laravel-6
1个回答
0
投票

整个web.php如下:

Route::get('/', 'LandingController@index');
Route::get('/news', 'PostController@index');
Route::get('/news/{id}', 'PostController@index');
Route::post('/news/{id}/addcomment', 'CommentController@store');
Route::get('/news/{id}/comment/{id}/edit', 'CommentController@edit');
Route::put('/news/{id}/comment/{id}', 'CommentController@update');
Route::delete('/news/{id}/comment/{id}', 'CommentController@destroy');
Route::get('/contact', 'ContactController@index');
Route::get('/contact/location', 'ContactController@sendlocation');

Route::prefix('admin')->group(function () {
    Route::any('/{query}/', function () {
        return view('admin');
    })->where('query', '.*');
});

我想在这里存档的原因是,我的管理部分完全由vue.js处理,因为它是处理大多数工作的完整Office应用程序。最有可能采用PWA的形式(当前仍是多页应用程序,并且仍处于开发阶段)。

由于有些客户只想浏览而不使用该应用程序,因此对于他们来说下载整个应用程序只是为了浏览新闻或任何简单的获取信息都是没有意义的。但是,使用应用程序本身是另一回事。

所以...该计划是让登陆,新闻和联系页面保留为常规html页面。仅管理部分位于vue.js中。

© www.soinside.com 2019 - 2024. All rights reserved.