所有
我开发了一个新的辅助站点。用户将使用以下引用从主站点引用此站点:http://auxiliary-site?ownerId=some-guid
我制作了AppRoutingModule:
true
我将此模块引用到AppModule:
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AppComponent } from './app.component';
import { ConfigurationsComponent } from './configurations/configurations.component';
import { CreateConfigurationComponent } from './create-configuration/create-configuration.component';
import { PageNotFoundComponent } from './pageNotFound/pageNotFound.component';
const routes: Routes = [
{ path: ':ownerId', redirectTo: 'new-configuration/:ownerId', pathMatch: 'full' },
{ path: 'configurations/:ownerId', component: ConfigurationsComponent },
{ path: 'new-configuration/:ownerId', component: CreateConfigurationComponent },
{ path: '**', component: PageNotFoundComponent }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
但是我启动了我的应用并转到http://localhost:3000?ownerId=some-guid或http://localhost:3000/new-configuration?ownerId=some-guid我发现:404页面未找到。
我可以修复此错误吗?
答案 0 :(得分:0)
将网址称为' http://localhost:3000/new-configuration/some-guid'。如果您想在网址中使用querystring参数,则可以删除':ownerId'部分来自路线配置。
答案 1 :(得分:0)
根据定义的路线,URL写法的方式将是这样的
http://localhost:3000/some-guid
http://localhost:3000/new-configuration/some-guid
在这种情况下,无需添加查询参数。