首页 文章

位置和HashLocationStrategy在测试版中停止工作

提问于
浏览
14

错误信息

VM556 angular2-polyfills.js:349错误:必须定义令牌!(...)

要么

错误TS2305:模块'“/ node_modules / angular2 / router”'没有导出成员'LocationStrategy' . 错误TS2305:模块'“/ node_modules / angular2 / router”'没有导出成员'HashLocationStrategy' . 错误TS2305:模块'“/ node_modules / angular2 / router”'没有导出的成员'Location' .

怎么修

1 回答

  • 29

    update >= rc.5

    @NgModule({
      providers: [{ provide: LocationStrategy, useClass: HashLocationStrategy}]
    })
    export class AppModule {}
    

    update >= rc.0

    import {  
      PlatformLocation,  
      Location,  
      LocationStrategy,  
      HashLocationStrategy,  
      PathLocationStrategy,  
      APP_BASE_HREF}  
    from '@angular/common';  
    
    import {BrowserPlatformLocation} from   '@angular/platform-browser';
    

    original

    更改

    import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from 'angular2/router';
    

    import {ROUTER_PROVIDERS} from 'angular2/router';
    import {LocationStrategy, HashLocationStrategy} from 'angular2/platform/common';
    

    也可以看看

    已移动出口的完整列表:

    import {  
      PlatformLocation,  
      Location,  
      LocationStrategy,  
      HashLocationStrategy,  
      PathLocationStrategy,  
      APP_BASE_HREF}  
    from 'angular2/platform/common';  
    
    import {BrowserPlatformLocation} from   'angular2/src/platform/browser/location/browser_platform_location';
    

    通常由此更改引起的另一个错误是

    location.createComponent不是函数

相关问题