模块'“node_modules / @ angular / router / index”'没有导出成员'OnActivate'

时间:2016-10-18 10:59:50

标签: angular typescript routes

行为

按照https://angular.io/docs/ts/latest/guide/router.html处的文档添加以下行

import {OnActivate, RouteSegment, RouteTree} from "@angular/router";

然后我运行服务并获得以下错误

ERROR in [default] /Users/~/src/app/stock-item/stock-item.component.ts:3:8 
Module '"/Users/~/node_modules/@angular/router/index"' has no exported member 'OnActivate'.

ERROR in [default] /Users/~/src/app/stock-item/stock-item.component.ts:3:20 
Module '"/Users/~/node_modules/@angular/router/index"' has no exported member 'RouteSegment'.

ERROR in [default] /Users/~/src/app/stock-item/stock-item.component.ts:3:34 
Module '"/Users/~/node_modules/@angular/router/index"' has no exported member 'RouteTree'.

1 个答案:

答案 0 :(得分:1)

可能您使用的是旧版本的角度版本,并且在最新的角度版本OnActivateRouteSegmentRouteTree已弃用,因此您必须根据它对代码进行更改。您可以检查角度router api reference。您还可以查看angular change log以检查版本OnActivateRouteSegmentRouteTree的版本是否已被弃用。