Redirect within MapUnknownRoutes in Aurelia

北城以北 提交于 2019-12-07 16:45:43

问题


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');

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?


回答1:


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

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

See the complete signature of the method on github



来源:https://stackoverflow.com/questions/33280224/redirect-within-mapunknownroutes-in-aurelia

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!