转换到父具有动态段的子路径

TransitionTo child path where parent has dynamic segment

本文关键字:路径 动态 转换      更新时间:2023-09-26

正如标题所暗示的那样,我正在尝试从操作中transitionTo子路径。问题是 Ember 说它找不到任何具有该名称的路径。看着 Ember 文档,我不知道我在这里做错了什么。我希望这里有人有专业知识来帮助我。

余烬错误:

Uncaught Error: Assertion Failed: The route post.comments was not found

应用程序路由定义:

this.resource('post', { path: 'post/:post_id' }, function () {
    this.resource('comments');
});

操作中的transitionTo

route.transitionTo('post.comments', post_id);
路由

post.comments不存在,因为您将comments定义为resource而不是route。我想这应该有效:

this.resource('post', { path: 'post/:post_id' }, function () {
    this.route('comments');
});
route.transitionTo('post.comments', post_id);

但是,如果确实需要将comments声明为资源,请使用:

route.transitionTo('comments', post_id);