首页 文章

Angular2 beta 7上的HashLocationStrategy

提问于
浏览
1

我只是想知道如何处理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不需要基本标记 .

EXCEPTION:实例化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 ORIGINAL EXCEPTION:没有设置基本href . 请提供APP_BASE_HREF标记的值或向文档添加基本元素 .

HashLocationStrategy如何在beta 7中运行?

问候

1 回答

  • 1

    原始异常:没有设置基本href . 请提供APP_BASE_HREF标记的值或向文档添加基本元素 .

    <base href='/'>
    

    到你的标记 .

相关问题