我有这个...
this.router.navigate(['search', this.searchParameters]);
这会生成类似 '/search;text=test;dateFrom=12-10-2016'
这很好用!
但是...如果我刷新浏览器或在 URL 地址栏上按回车,我将得到 404...
无法获取 /search;text=test;dateFrom=12-10-2016
使用 angular 2 beta 可以正常工作,因为 beta 使用的是标准查询字符串格式,例如 ?text=test&dateFrom=12-10-2016。
现在,最终的 Angular 2 使用 Url Matrix Notation 来处理来自 URL 的参数。
关于如何使这项工作的任何线索?
不确定它是否有帮助,但这是我的 app.routing.ts
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './components/pages/home/home.component';
import { SearchComponent } from './components/pages/search/search.component';
const appRoutes: Routes = [
{
path: '',
redirectTo: '/home',
pathMatch: 'full'
},
{
path: 'search',
component: SearchComponent
}
];
导出常量路由:ModuleWithProviders = RouterModule.forRoot(appRoutes);
另外,我的 gulp/browserSync 上有这个...
browserSync.init({
server: {
baseDir: "./",
routes: {
"/home": "index.html",
"/search": "index.html"
}
}
});