我在更新到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 })
];
答案 0 :(得分:5)
RouterConfig
似乎没有导出@angular/router
个属性。请尝试使用Routes
。
const routes: Routes = [ // <==
{
path: '',
redirectTo: '/login',
terminal: true
},
{
path: 'login',
component: LoginComponent
},
{
path: 'dashboard',
component: DashboardComponent
}
];
答案 1 :(得分:2)
我遇到了同样的问题,但问题的根源是我使用的包是用 angular 2 构建的,而项目是用 angular 4构建的。虽然,包适用于版本2+,问题是该方法期望旧的(ng2)路由,但是给了新的(ng4)路由。 显然存在差异。
我的解决方案是删除类型定义,将路由作为任何类型传递。