此錯誤在我彈出時寫路線我的應用程序類型'({path:string; redirectTo:string; pathMatch:string;} | {path:string; component:typeof Rec ...'is not assignable to type'Route []
Type '({ path: string; redirectTo: string; pathMatch: string; } | { path: string; component: typeof Rec...' is not assignable to type 'Route[]
我的路線文件
import {RouterModule, Routes} from '@angular/router';
import {RecipesComponent} from './recipes/recipes.component';
import {ShoppingListComponent} from './shopping-list/shopping-list.component';
import {recipe_routing} from "./recipes/recipe.routes";
const approutes: Routes = [
{path: '', redirectTo: '/recipes', pathMatch: 'full'},
{path: 'recipes', component: RecipesComponent, children: recipe_routing},
{path: 'shopping-list', component: ShoppingListComponent}
];
export const routing = RouterModule.forRoot(approutes);
什麼錯誤,我是用這個文件它不是working.It做說approutes(常量,我已分配)是一個不工作
配方路由
import {Routes} from "@angular/router";
import {RecipeStartComponent} from "./recipe-start.component";
import {RecipeEditComponent} from "./recipe-edit/recipe-edit.component";
import {RecipeDetailComponent} from "./recipe-detail/recipe-detail.component";
export const recipe_routing: Routes = [
{path: '', component: RecipeStartComponent},
{path: 'new', component: RecipeEditComponent},
{path: ':id', component: RecipeDetailComponent},
{path: ':id/edit', component: RecipeEditComponent}
];
這是配方路由
我沒有寫export const routing = RouterModule.forRoot(approutes);
,因爲這僅僅是一個孩子的路線。
嘗試這樣'常量approutes:路線[] = [...]' –
可您發佈'recipe_routing'?這個問題很可能存在 – PierreDuc
我已經包含了它,而Maximus的工作方式不是這樣,一個錯誤說類型'ModuleWithProviders'不能分配類型'Route []'。彈出 – Mannish