简体   繁体   English

Angular2 beta 7上的HashLocationStrategy

[英]HashLocationStrategy on Angular2 beta 7

I just want to know how to handle the HashlocationStrategy from angular2 beta 7? 我只想知道如何从angular2 beta 7处理HashlocationStrategy? My Code from beta 3 does not work anymore. Beta 3版的我的代码已无法使用。

What I have: 我有的:

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})
]);

and I get the error to set a base tag. 我收到设置基本标签的错误。 But HashLocationStrategy did not require a base tag. 但是HashLocationStrategy不需要基本标记。

EXCEPTION: Error during instantiation of LocationStrategy! 例外:在实例化LocationStrategy时出错! (RouterLink -> Router -> Location -> LocationStrategy).BrowserDomAdapter.logError @ angular2.dev.js:23083BrowserDomAdapter.logGroup @ angular2.dev.js:23094ExceptionHandler.call @ angular2.dev.js:1185(anonymous function) @ angular2.dev.js:12591NgZone._notifyOnError @ angular2.dev.js:13635collection_1.StringMapWrapper.merge.onError @ angular2.dev.js:13539Zone.run @ angular2-polyfills.js:1247(anonymous function) @ 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(anonymous function) @ angular2-polyfills.js:123microtask @ angular2.dev.js:13590Zone.run @ angular2-polyfills.js:1243(anonymous function) @ angular2.dev.js:13558zoneBoundFn @ angular2-polyfills.js:1220lib$es6$promise$asap$$flush @ angular2-polyfills.js:262 angular2.dev.js:23083 ORIGINAL EXCEPTION: No base href set. (RouterLink->路由器->位置-> 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 $$内部$$发布@ 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。 Please provide a value for the APP_BASE_HREF token or add a base element to the document. 请提供APP_BASE_HREF令牌的值,或将基本元素添加到文档中。

How is HashLocationStrategy working in beta 7? HashLocationStrategy在beta 7中如何工作?

Regards 问候

ORIGINAL EXCEPTION: No base href set. 原始例外:未设置基本href。 Please provide a value for the APP_BASE_HREF token or add a base element to the document. 请提供APP_BASE_HREF令牌的值,或将基本元素添加到文档中。

Add

<base href='/'>

to your markup. 给你的标记。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM