鍍金池/ 問答/HTML5  HTML/ Angular2路由不支持多次重定向嗎?

Angular2路由不支持多次重定向嗎?

Angular2路由不支持多次重定向嗎?

根路由模塊

# app.routing.module

import { NgModule } from '@angular/core';
import { RouterModule, Routes }  from '@angular/router';

// 根路由列表
const routes: Routes = [
    { path: '',  redirectTo: 'manage', pathMatch: 'full' }
];

@NgModule({
    imports: [ RouterModule.forRoot(routes, { enableTracing: true, useHash: true }) ],
    exports: [ RouterModule ]
})
export class AppRoutingModule {}

管理模塊路由列表

const manage_routes: Routes = [
    {
        { path: 'manage',   redirectTo: 'manage/dashboard_conf', pathMatch: 'full' },
        { path: 'manage/dashboard_conf', component: DashboardConfComponent },

        { path: 'manage/image_upload', component: ImageUploadComponent },
        { path: 'manage/image_conf', component: ImageConfComponent }
    }
]

我原先的想法是
127.0.0.1:8888 重定向 127.0.0.1:8888/manage
127.0.0.1:8888/manage 重定向 127.0.0.1:8888/manage/dashboard_conf

報(bào)錯(cuò):
Invalid configuration of route ''. One of the following must be provided: component, redirectTo, children or loadChildren

請(qǐng)教如何實(shí)現(xiàn)?

回答
編輯回答
空白格
const manage_routes: Routes = [
    { path: 'manage',   redirectTo: 'manage/dashboard_conf', pathMatch: 'full' },
    { path: 'manage/dashboard_conf', component: DashboardConfComponent },

    { path: 'manage/image_upload', component: ImageUploadComponent },
    { path: 'manage/image_conf', component: ImageConfComponent }
]

寫錯(cuò)了,應(yīng)該是上面的路由列表。
Angualr2是支持路由多次重定向的。

2018年8月17日 03:18