gpt4 book ai didi

javascript - Ember.js 中的条件重定向

转载 作者:行者123 更新时间:2023-12-03 10:17:01 27 4
gpt4 key购买 nike

只有当我位于重定向路由而不是其子路由上时,是否有一种干净的方法来重定向?

App.IndexRoute = Em.Route.extend({
...
redirect: function(record, transition) {
if(transition.targetName === 'index')
this.replaceWith('index.nested');

当我删除 if 时,每次刷新 index 的嵌套路由时都会触发重定向。

Transition 类是私有(private)的(不知道为什么我什至在它是私有(private)的情况下在这里得到它),所以我不应该将它用于此类内容。

最佳答案

使用不同的示例,例如位于 /postsPostsRou​​te (因为 Index 是“特殊”)也只会加载 PostsIndexRoute您可以在其中放置重定向代码的父级。对 /posts/new 的访问不会重定向。

关于javascript - Ember.js 中的条件重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29827736/

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