gpt4 book ai didi

Polymer 应用程序路由重定向

转载 作者:行者123 更新时间:2023-12-02 05:20:42 28 4
gpt4 key购买 nike

我正在使用 <app-route>在 polymer 中。一切正常,除了重定向。我读过 https://www.polymer-project.org/1.0/toolbox/routing ,解释似乎很清楚,但由于某种原因,它并没有按照我想要的方式工作。

在 View 下方的某处我有一个元素...

<script>
Polymer({
is: 'user-auth',
responseHandler: function(event) {
var token = event.detail.response.d.token;
if (token != '') {
localStorage.setItem('access_token', token);
this.set('route.path', '/hello');
}

}
});
</script>

问题是,它重定向到 /x/y/z/hello而不是 /hello作为绝对网址。我怎样才能使重定向成为绝对的?

最佳答案

没有 <app-route>很难说。

另一个(肮脏的)选项是:

<style>
#redirect {
display: none;
}
</style>

...

<a id="redirect" href="/hello"></a>

...

<script>
...
// at the place where you want to redirect
this.$.redirect.click();
...
</script>

关于Polymer 应用程序路由重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37689515/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com