Polymer 是否可以使用<;重写URL;应用程序路线>;?
假设我想将URL从Polymer 是否可以使用<;重写URL;应用程序路线>;?,polymer,app-route,Polymer,App Route,假设我想将URL从/register重写为/tenant/register,其中:- /register没有实际的视图,因为它只会让URL更漂亮 /tenant/register是实际视图,带有视图元素 是否可以使用重写URL?因此,它可以有一个虚拟路径,并根据特定规则重定向到应用程序路径。关于问题的标题,添加: <app-location route="{{newRoute}}"></app-location> 此.set方法将引导您的新目标,就像您按下了以PSK
/register
重写为/tenant/register
,其中:-
没有实际的视图,因为它只会让URL更漂亮/register
是实际视图,带有/tenant/register
视图元素
是否可以使用
重写URL?因此,它可以有一个虚拟路径,并根据特定规则重定向到应用程序路径。关于问题的标题,添加:
<app-location route="{{newRoute}}"></app-location>
此.set
方法将引导您的新目标,就像您按下了
以PSK为例,我们需要在
中添加一个路径更改的
侦听器,如下所示:-
<app-location id="location"
route="{{route}}"
url-space-regex="^[[rootPath]]"
on-path-changed="rewritePath">
</app-location>
/**
* Rewrite path before passing to <app-route>
*/
rewritePath() {
let location = this.$.location;
let path = location.path;
if (path == '/register') {
location.path = '/tenant/register';
}
}
这不是我想要的,因为我已经知道如何通过设置
route.path
来更改路由。我打算在路径通过
获得进程之前重写它。你的回答确实给了我一个我正在寻找的答案的提示,我将与大家分享。谢谢其实我也这么想,;我明白了,这个答案并不是我在读你的问题时你想要的答案,但我保留了它,而不是删除它,这可能会给你另一个想法
/**
* Rewrite path before passing to <app-route>
*/
rewritePath() {
let location = this.$.location;
let path = location.path;
if (path == '/register') {
location.path = '/tenant/register';
}
}