本文介绍了Angular 2路由器中间的通配符选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Angular.js 2开发一个项目.我正在尝试使用路由器.

I am trying to develop a project with Angular.js 2. I am trying to use the router.

我正在尝试创建一条带有参数的路由以捕获如下内容:

I am trying to create a route with parameters to catch things like following:

/m/SOMETHING1/c/SOME/THING2/p/SOMETHING3

请注意,SOME/THING2是一个字符串,其中可能包含0个或多个

我需要的路线定义"如下所示:{ path: "/m/:sth1Var/c/*sth2Var/p/:sth3Var", component: MultiPost, name: "RouteName" }

What I need for Route Definition is something like:{ path: "/m/:sth1Var/c/*sth2Var/p/:sth3Var", component: MultiPost, name: "RouteName" }

但是我找不到在中间使用通配符(*)的方法.

But I couldn't find a way to use wildcard character (*) in the middle.

我要实现的目标是否可能没有捕获所有URL并自己解析整个目标?

Is the thing I am trying to achieve is possible without capturing all url and parsing whole thing myself?

推荐答案

我认为您无法使用路由定义来实现.您应该将其从路线移到参数或单独的路线中.

I don't think you can achieve that with routes definitions. You should move that out of the route into params or separate routes.

这篇关于Angular 2路由器中间的通配符选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 15:18