Angular 2:类型’Route []’的参数不能分配给’Route []’类型的参数.

前端之家收集整理的这篇文章主要介绍了Angular 2:类型’Route []’的参数不能分配给’Route []’类型的参数.前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当我更新到nativescript-angular的最后一个版本时,我收到此错误,我想这个问题与我正在使用的Angular 2版本和模块使用的版本之间的差异有关.是否有人能够告诉我应该使用哪些正确的版本才能使其正常工作?
请注意,我打算升级到nativescript-angular的最后一个版本是使用RouterExtensions.

Argument of type 'Route[]' is not assignable to parameter of type  'Route[]'.
  Type 'Route' is not assignable to type 'Route'.
    Types of property 'pathMatch' are incompatible.
      Type 'string' is not assignable to type '"full" | "prefix"'.
        Type 'string' is not assignable to type '"prefix"'.
const routes: Route[]

这些是我的package.json依赖项:

"dependencies": {
    "@angular/common": "2.0.0-rc.4","@angular/compiler": "2.0.0-rc.4","@angular/core": "2.0.0-rc.4","@angular/forms": "0.3.0","@angular/http": "2.0.0-rc.4","@angular/platform-browser": "2.0.0-rc.4","@angular/platform-browser-dynamic": "2.0.0-rc.4","@angular/platform-server": "2.0.0-rc.4","@angular/router": "^3.0.0-rc.1","@angular/router-deprecated": "2.0.0-rc.2","@angular/upgrade": "2.0.0-rc.4","nativescript-angular": "^0.3.1","nativescript-plugin-firebase": "^3.5.3","reflect-Metadata": "^0.1.8","rxjs": "5.0.0-beta.6","tns-core-modules": "^2.3.0-2016-08-29-3966","zone.js": "^0.6.17"
  },

app.routes.ts:

import { RouterConfig } from '@angular/router';
import { nsProvideRouter} from 'nativescript-angular/router';
import { LoginComponent } from './components/login.component';
import { DashboardComponent } from './components/dashboard.component';


const routes: RouterConfig = [
    {
        path: '',redirectTo: '/login',terminal: true
    },{ 
        path: 'login',component: LoginComponent
    },{
        path: 'dashboard',component: DashboardComponent
    }
];


export const APP_ROUTER_PROVIDERS = [
    nsProvideRouter(routes,{ enableTracing: false })
];

解决方法

似乎没有@ angular / router导出的属性RouterConfig.请尝试使用路由.

const routes: Routes = [ // <==
    {
        path: '',component: DashboardComponent
    }
];

猜你在找的Angularjs相关文章