在Aurelia中的MapUnknownRoutes中重定向 [英] Redirect within MapUnknownRoutes in Aurelia

查看:80
本文介绍了在Aurelia中的MapUnknownRoutes中重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望不良路线导航到根路线.我在路由器上添加了mapUnknownRoutes配置.

I want bad routes to navigate to the root route. I've added a mapUnknownRoutes configuration on my router.

config.mapUnknownRoutes((inst) => inst.config.moduleId = 'home');

但这使路线保持不变.例如,#/fakeRoute路由到家.理想情况下,我想要一种类似于返回{ redirect: '#/' }的行为,该行为将取消导航并创建对路径'#/'的新导航.这是功能吗?

But this leaves the route untouched. For example, #/fakeRoute routes to home. Ideally, I would like a behavior similar to returning { redirect: '#/' }, which cancels navigation and creates a new navigation to the route '#/'. Is this a feature?

推荐答案

mapUnknownRoutes方法还接受

The mapUnknownRoutes method also accepts a RouteConfig object so you can just directly specify your redirect there:

config.mapUnknownRoutes({ redirect: '#/' });

请参见 github

这篇关于在Aurelia中的MapUnknownRoutes中重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆