我正在我的角度流星应用程序中实现路由,但却得到Module '"node_modules/@angular/router/index"' has no exported member 'RouterModule'.
和Module '"node_modules/@angular/router/index"' has no exported member 'Routes'
的打字稿错误
任何帮助都会非常感激。
app.routes文件是
import { RouterModule, Routes } from '@angular/router';
import { LoginComponent } from '../../components/login/login.component';
import { SignupComponent } from '../../components/signup/signup.component';
import { ResourcesComponent } from '../../components/resources/resources.component';
import { MyApp } from './app.component';
export const routes: Routes=[
{path:'',component:MyApp},
{path:'login',component:LoginComponent},
{path:'signup', component:SignupComponent},
{path:'resources',component:ResourcesComponent},
];
package.json
{
"name": "test",
"private": true,
"scripts": {
"start": "meteor run"
},
"dependencies": {
"@angular/common": "^4.2.3",
"@angular/compiler": "^4.2.3",
"@angular/compiler-cli": "^4.2.3",
"@angular/core": "^4.2.3",
"@angular/forms": "^4.2.3",
"@angular/http": "^4.2.3",
"@angular/platform-browser": "^4.2.3",
"@angular/platform-browser-dynamic": "^4.2.3",
"@angular/platform-server": "^4.2.3",
"@angular/router": "3.0.0-rc.1",
"@angular/router-deprecated": "2.0.0-rc.2",
"babel-runtime": "^6.20.0",
"meteor-node-stubs": "~0.2.4",
"meteor-rxjs": "^0.4.7",
"reflect-metadata": "^0.1.10",
"rxjs": "^5.4.1",
"zone.js": "^0.8.12"
},
"devDependencies": {
"@types/meteor": "^1.4.2",
"@types/meteor-accounts-phone": "0.0.5",
"@types/underscore": "^1.8.1",
"meteor-typings": "^1.3.1"
}
}
答案 0 :(得分:0)
在app.route模块中添加此
import { RouterModule, Routes } from '@angular/router';
import { LoginComponent } from '../../components/login/login.component';
import { SignupComponent } from '../../components/signup/signup.component';
import { ResourcesComponent } from '../../components/resources/resources.component';
import { MyApp } from './app.component';
export const routes: Routes = [
{path:'',component:MyApp},
{path:'login',component:LoginComponent},
{path:'signup', component:SignupComponent},
{path:'resources',component:ResourcesComponent},
];
@NgModule({
imports: [ RouterModule.forRoot(routes) ],
exports: [ RouterModule ]
})
export class AppRouteModule {
}
并在app.module中导入此模块
import { AppRouteModule } from './app.route.module';
并注册模块
@NgModule({
...
imports: [ AppRouteModule ],
...
})
export class AppModule{
}