[英]routing in Angular 2 (v6 )
我在Angular 2(v6)中的路由遇到一些问题
该网站的结构如下:
(root,site.com /)
---- subfolder1(site.com/subfolder1)
---- subfolder2(site.com/subfolder2)
---- client(site.com/client)<< Anuglar网站
部署时,我们使用的是:ng build --prod --deploy-url = / client /
出于某种原因,当我们导航到site.com/client/quote/88b02e09-511b-40c5-a64a-a3aeb2b9d239时,它总是转到PageNotFoundComponent
我们的路线参数:
const路由:路由= [{路径:”,组件:QuoteSearchComponent},{路径:'quote /:guid',组件:QuoteComponent},{路径:'**',组件:PageNotFoundComponent}];
main.9a26b5fe0012f4ac3aae.js:1 GuardsCheckEnd(id:1,url:'/ quote / 88b02e09-511b-40c5-a64a-a3aeb2b9d239',urlAfterRedirects:'/ quote / 88b02e09-511b-40c5-a64a-a3aeb2b9d (url:'',path:''){Route(url:'quote / 88b02e09-511b-40c5-a64a-a3aeb2b9d239',path:'quote /:guid')},应激活:true)main.9a26b5fe0012f4ac3aae.js :1 e {id:1,网址:“ / quote / 88b02e09-511b-40c5-a64a-a3aeb2b9d239”,urlAfterRedirects:“ / quote / 88b02e09-511b-40c5-a64a-a3aeb2b9d239”,状态:e,应该激活:true} main.9a26b5fe0012f4ac3aae.js:1路由器事件:e main.9a26b5fe0012f4ac3aae.js:1 ResolveStart(id:1,url:'/ quote / 88b02e09-511b-40c5-a64a-a3aeb2b9b239',urlAfterRedirects:'02 / quote / -40c5-a64a-a3aeb2b9d239',状态:Route(url:'',path:''){Route(url:'quote / 88b02e09-511b-40c5-a64a-a3aeb2b9d239',path:'quote /:guid') })main.9a26b5fe0012f4ac3aae.js:1 e {id:1,url:“ / quote / 88b02e09-511b-40c5-a64a-a3aeb2b9d239”,urlAfterRedirects:“ / quote / 88b02e09-511b-40c5-a64a-a3aeb2b9 :e} main.9a 26b5fe0012f4ac3aae.js:1路由器事件:e main.9a26b5fe0012f4ac3aae.js:1 ResolveEnd(id:1,url:'/ quote / 88b02e09-511b-40c5-a64a-a3aeb2b9d239',urlAfterRedirects:'/ quote / 88b02 -a64a-a3aeb2b9d239',状态:Route(url:'',path:''){Route(url:'quote / 88b02e09-511b-40c5-a64a-a3aeb2b9d239',path:'quote /:guid')}) main.9a26b5fe0012f4ac3aae.js:1 e {id:1,url:“ / quote / 88b02e09-511b-40c5-a64a-a3aeb2b9d239”,urlAfterRedirects:“ / quote / 88b02e09-511b-40c5-a64a-a3aeb2b9d239, } main.9a26b5fe0012f4ac3aae.js:1路由器事件:t main.9a26b5fe0012f4ac3aae.js:1 ActivationEnd(path:'quote /:guid')main.9a26b5fe0012f4ac3aae.js:1 t {snapshot:t} main.9a26b1fe1路由器事件:t main.9a26b5fe0012f4ac3aae.js:1 ChildActivationEnd(path:'')main.9a26b5fe0012f4ac3aae.js:1 t {snapshot:t} main.9a26b5fe0012f4ac3aae.js:1路由器事件:e main.9a26b5fe0012 (id:1,url:'/ quote / 88b02e09-511b-40c5-a64a-a3aeb2b9d239',urlAfterRedirects:'/ quote / 88b02e09-511b-40c5-a 64a-a3aeb2b9d239')main.9a26b5fe0012f4ac3aae.js:1 e {id:1,url:“ / quote / 88b02e09-511b-40c5-a64a-a3aeb2b9d239”,urlAfterRedirects:“ / quote / 88b02e09-511b9c-40a5-a “}
我需要有关您要做什么的更多信息,但请参考我的示例作为指导:
最佳实践表明,您始终需要在语句中放入路径值。
import { RouterModule, Routes } from '@angular/router'
import { HomeComponent } from './components/home/home.component';
import { AboutComponent } from './components/about/about.component'
import { HeroesComponent } from './components/heroes/heroes.component'
const APP_ROUTES: Routes = [
{ path: 'home', component: HomeComponent},
{ path: 'about', component: AboutComponent},
{ path: 'heroes', component: HeroesComponent},
{ path: '**', pathMatch: 'full', redirectTo: 'home'}
]
export const APP_ROUTING = RouterModule.forRoot(APP_ROUTES, { useHash: true });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.