当我尝试在浏览器上访问我的路线UnrecognizedUrl
时,我收到dashboard/posts/id/comments
错误。以下是我的router.js
我想询问我的路由器是wrong
还是有人请告诉我正确的方法
this.route('dashboard', function() {
this.route('posts', function() {
this.route('show', { path: ':post_id' }, function() {
this.route('comments', { path: ':post_id/comments'}, function() { });
});
});
});
但是,如果我将{{outlet}}
放在我的资源文件app/pods/dashboard/posts/show/template.hbs
上,那么当我将app/pods/dashboard/posts/show/comments/template.hbs
更改为
router.js
上的内容
this.route('dashboard', function() {
this.route('posts', function() {
this.route('show', { path: ':post_id' }, function() {
this.route('comments');
});
});
});
我的目标是,我希望在浏览器网址应为app/pods/dashboard/posts/show/comments/template.hbs
的其他网页上显示dashboard/posts/id/comments
的内容
答案 0 :(得分:0)
应该是
this.route('dashboard', function() {
this.route('routeA', function() {
this.route('childRouteA', { path: '/:childRouteA_id' }, function() {
this.route('childRouteAb');
});
});
});
例如:信息中心/路线A / id / childRouteAb
如果childRouteAb
是动态ID,那么它应该是
this.route('dashboard', function() {
this.route('routeA', function() {
this.route('childRouteA', { path: '/:childRouteA_id' }, function() {
this.route('childRouteAb', { path: '/:childRouteAb'});
});
});
});
例如:信息中心/ routeA / id / id2
如果你需要url在id之前指定id的类型,你可以这样做。
this.route('dashboard', function() {
this.route('routeA', function() {
this.route('childRouteA', { path: '/childRouteA/:childRouteA_id' }, function() {
this.route('childRouteB', { path: '/childRouteB/:childRouteB_id'});
});
});
});
例如:信息中心/路线A / childRouteA / id1 / childRouteB / id2