【问题标题】:Route prefix like in laravel api像 laravel api 一样的路由前缀
【发布时间】:2019-02-19 06:30:20
【问题描述】:

是否可以像在 laravel 中一样制作 Angular 7 路由前缀?

Route::group(['prefix' => 'v1'], function (){
    Route::get('categories', 'Api\ApiCategoryController@listOfCategories');
});

在上面的代码中,我的网址是https://example.com/api/v1/categories。如何在 Angular 7 中制作这样的网址?

【问题讨论】:

    标签: angular laravel routes


    【解决方案1】:

    你可以试试:

    const parentModuleRoutes: Routes = [
        {
            path: 'parent-component',            //<---- parent component declared here
            component: PetParentComponent,
            children: [                          //<---- child components declared here
                {
                    path:'child-one',
                    component: ChildOneComponent
                },
                {
                    path:'child-two',
                    component: ChildTwoComponent
                },
                {
                    path:'child-three',
                    component: ChildThreeComponent
                },
                {
                    path:'child-four',
                    component: ChildFourComponent
                },
            ]
        }
    ];
    

    希望能帮到你^_^

    【讨论】:

    • 是否也应该在routerLink中设置父路径,比如routerLink="parent-component/child-one"
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-16
    • 2018-07-07
    • 2016-03-26
    • 2019-09-07
    • 1970-01-01
    • 2013-01-05
    • 1970-01-01
    相关资源
    最近更新 更多