【发布时间】:2016-06-07 09:57:27
【问题描述】:
我只是想知道如何处理来自 angular2 beta 7 的 HashlocationStrategy?我的 beta 3 代码不再有效。
我有什么:
import {bootstrap} from 'angular2/platform/browser';
import {Component, provide} from 'angular2/core';
import {APP_BASE_HREF, ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from 'angular2/router';
import {AppComponent} from './app.component';
bootstrap(AppComponent, [
ROUTER_PROVIDERS,
provide(LocationStrategy, {useClass: HashLocationStrategy})
]);
我收到设置基本标签的错误。但是 HashLocationStrategy 不需要基本标记。
异常:LocationStrategy 实例化期间出错! (RouterLink -> Router -> Location -> LocationStrategy).BrowserDomAdapter.logError @ angular2.dev.js:23083BrowserDomAdapter.logGroup @ angular2.dev.js:23094ExceptionHandler.call @ angular2.dev.js:1185(匿名函数) @ angular2 .dev.js:12591NgZone._notifyOnError @ angular2.dev.js:13635collection_1.StringMapWrapper.merge.onError @ angular2.dev.js:13539Zone.run @ angular2-polyfills.js:1247(匿名函数)@ angular2.dev.js :13558zoneBoundFn @ angular2-polyfills.js:1220lib$es6$promise$$internal$$tryCatch @ angular2-polyfills.js:468lib$es6$promise$$internal$$invokeCallback @ angular2-polyfills.js:480lib$es6$promise $$internal$$publish @ angular2-polyfills.js:451(匿名函数) @ angular2-polyfills.js:123microtask @ angular2.dev.js:13590Zone.run @ angular2-polyfills.js:1243(匿名函数) @ angular2 .dev.js:13558zoneBoundFn @ angular2-polyfills.js:1220lib$es6$promise$asap$$flush @ angular2-polyfills.js:262 angular2.dev.js:23083 原始异常:未设置基本 href。请为 APP_BASE_HREF 令牌提供值或向文档添加基本元素。
HashLocationStrategy 在 beta 7 中是如何工作的?
问候
【问题讨论】:
-
根据
angular2 changelog,HashlocationStrategy的beta-7没有变化。在这里查看github.com/angular/angular/blob/master/… -
尝试将 node_modules 复制到您的 www 根文件夹中
标签: javascript angular