Location 和 HashLocationStrategy 在 beta.16 中停止工作 [英] Location and HashLocationStrategy stopped working in beta.16

查看:15
本文介绍了Location 和 HashLocationStrategy 在 beta.16 中停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误信息

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

VM556 angular2-polyfills.js:349Error: Token must be defined!(…)

错误 TS2305:模块 '"/node_modules/angular2/router"' 没有导出成员 'LocationStrategy'.
错误 TS2305:模块 '"/node_modules/angular2/router"' 没有导出成员 'HashLocationStrategy'.
错误 TS2305:模块/node_modules/angular2/router"没有导出成员位置".

error TS2305: Module '"/node_modules/angular2/router"' has no exported member 'LocationStrategy'.
error TS2305: Module '"/node_modules/angular2/router"' has no exported member 'HashLocationStrategy'.
error TS2305: Module '"/node_modules/angular2/router"' has no exported member 'Location'.

如何修复

推荐答案

更新 >= rc.5

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

更新 >= rc.0

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

import {BrowserPlatformLocation} from   '@angular/platform-browser';

原创

改变

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

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

另见
- https://github.com/angular/angular/issues/8229

已移动导出的完整列表:
- https://github.com/angular/angular/pull/8230/files

Full list of moved exports:
- https://github.com/angular/angular/pull/8230/files

import {  
  PlatformLocation,  
  Location,  
  LocationStrategy,  
  HashLocationStrategy,  
  PathLocationStrategy,  
  APP_BASE_HREF}  
from 'angular2/platform/common';  

import {BrowserPlatformLocation} from   'angular2/src/platform/browser/location/browser_platform_location';

此更改通常导致的另一个错误是

Another error that's commonly caused by this change is

location.createComponent 不是函数

location.createComponent is not a function

这篇关于Location 和 HashLocationStrategy 在 beta.16 中停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆