我正在尝试设置一条路由,以便如果我点击http://localhost:8080/user/beta/
,它会重定向到http://localhost:8080/user/beta/#spreadsheet
,
并显示电子表格 View ,但我的代码重定向到:http://localhost:8080/#spreadsheet
。
import { provideRouter, RouterConfig } from '@angular/router';
import {Spreadsheet} from './components/spreadsheet/spreadsheet.component';
const routes: RouterConfig = [
{ path: '', redirectTo: 'spreadsheet', terminal: true },
{ path: 'spreadsheet', component: Spreadsheet }
];
export const APP_ROUTER_PROVIDERS = [
provideRouter(routes)
];
最佳答案
使用HashLocationStrategy
与 <base href="/user/beta">
定义 URL 的哪一部分是静态的。
关于javascript - 以 Angular 2 设置路线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38180217/