加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 17:01:50 所属栏目:安全 来源:网络整理
导读:当我更新到nativescript-angular的最后一个版本时,我收到此错误,我想这个问题与我正在使用的Angular 2版本和模块使用的版本之间的差异有关.是否有人能够告诉我应该使用哪些正确的版本才能使其正常工作? 请注意,我打算升级到nativescript-angular的最后一个
当我更新到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
    }
];

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读