相关疑难解决方法(0)

Angular2路由器保持查询字符串

我写了一个使用路由器的Angular2(v2.0.1)应用程序.该网站加载了几个查询字符串参数,因此完整的URL最初看起来像这样:

https://my.application.com/?param1=val1&param2=val2&param3=val3
Run Code Online (Sandbox Code Playgroud)

在我的路由配置中,我有一个重定向空路由的条目:

const appRoutes: Routes = [
    {
        path: '',
        redirectTo: '/comp1',
        pathMatch: 'full'
    },
    {
        path: 'comp1',
        component: FirstComponent
    },
    {
        path: 'comp2',
        component: SecondComponent
    }
];
Run Code Online (Sandbox Code Playgroud)

我的问题是,在应用程序被引导后,URL不再包含查询参数,而是看起来像这样:

https://my.application.com/comp1
Run Code Online (Sandbox Code Playgroud)

有没有什么办法可以配置路由器,以便在导航时保留初始查询字符串?

谢谢
Lukas

angular2-routing angular

57
推荐指数
5
解决办法
4万
查看次数

标签 统计

angular ×1

angular2-routing ×1