gpt4 book ai didi

angular - 设置路线时在 Angular 2中使用名称

转载 作者:太空狗 更新时间:2023-10-29 19:30:46 25 4
gpt4 key购买 nike

我有一个 angular 2 应用程序,它是用 angular 2 beta 14 编写的。我正在将它升级到 rc5。我正在使用最新的路由器,我的包 json 包含 "@angular/router": "3.0.0-rc.1"

以前的路由配置如下:

{path:'/...',name:'LoggedIn',component:LoggedInComponent},
{path:'/auth', name:'Auth', component:AuthComponent}

现在我是这样做的

import { RouterModule , Routes } from '@angular/router';
import {AuthComponent} from "./auth/auth.component";
import {LoggedInComponent} from "./auth/logged-in.component";
import {LOGGED_IN_ROUTES} from "./auth/logged-in.routes";
const APP_ROUTES : Routes = [
{ path : '/...' , name :'LoggedIn' , component : LoggedInComponent , children : LOGGED_IN_ROUTES},
{ path : '' , component : AuthComponent},
{ path : 'auth' , component : AuthComponent},

];
export const routing = RouterModule.forRoot(APP_ROUTES);

我收到类似这样的错误

Type '({ path: string; name: string; component: typeof LoggedInComponent; children: Route[]; } | { path...' is not assignable to type 'Route[]'.
Type '{ path: string; name: string; component: typeof LoggedInComponent; children: Route[]; } | { path:...' is not assignable to type 'Route'.
Type '{ path: string; name: string; component: typeof LoggedInComponent; children: Route[]; }' is not assignable to type 'Route'.
Object literal may only specify known properties, and 'name' does not exist in type 'Route'.

最佳答案

name 现已弃用,API 自测试版以来已升级,您可以阅读更多相关信息 here .

要检查如何配置路由和路由数组的架构,请参阅 this

希望这对您有所帮助!

关于angular - 设置路线时在 Angular 2中使用名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39359718/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com