简体   繁体   English

如何为单页面应用程序路由流明

[英]How to route Lumen for single page app

I'm using Lumen + Vue js to build an app. 我正在使用Lumen + Vue js来构建应用程序。 I have this code in routes.php 我在routes.php中有此代码

$app->get('{any}', function ()  {
    return view('vue', []);
});
$app->get('/', function ()  {
    return view('vue', []);
});

This works great for /login, /users, /anything . 这非常适合/ login,/ users和/ anything。 But when I add a subroute like /users/agents or /a/b, /a/b/c -> anything with more than one slash it gives me the 404 from lumen 但是,当我添加一个子路由(例如/ users / agents或/ a / b,/ a / b / c->带有多个斜线的任何东西)时,它会给我404流明值

You have the 404 error because {any} will not catch the parameters that contain slash. {any} 404错误,因为{any}将无法捕获包含斜杠的参数。 I order to make it do so, you need to add a pattern: 我要这样做,您需要添加一个模式:

$app->get('{any:.+}', function ()  {
    return view('vue', []);
});

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

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