问题描述
对于xxx / xxx之类的嵌套路由,如何正确使用通配符路由?
我想将host:port / XXX / XXX重定向到页面未找到,但是,我的通配路由仅接受路由host:port / XXX,而不接受host:port / XXX / XXX。
这是我在app.module.ts上配置的路由:
const routes: Routes = [
{
path: 'main',component: MainComponent
},{
path: '',component: PageNotFoundComponent
},{
path: '**',redirectTo: ''
}
];
RouterModule.forRoot(routes)
- 对于网址“ host:port / main”,我将获得主页。
- 对于网址“ host:port / XXXX”,我将获得未找到页面。
- 但是,对于URL'host:port / XXXX / XXXX',我会得到一个空白页面。
- 它只能成功下载index.html(并以“ XXXX”命名),没有style.css,没有资产,没有main.js。
- 使用ng服务和将其作为生产版本都存在相同的问题。
我的文件:(使用Angular 10.0.10)
app
--- page-not-found/page-not-found.component.ts
--- main/maincomponent.ts
--- app.component.ts
--- app.module.ts
assets
environment
index.html
main.ts
style.css
… (other files auto generated by angular cli)
谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)