问题描述
我尝试用emberjs构建一个webapp。这是应用程序路由器:
i try to build an webapp with emberjs. this is the app router:
App.Router.map(function() {
this.route("page");
this.route("menu");
this.resource('posts', function(){
this.resource('post', { path: '/:post_id' });
});
this.route("index", { path: "/" });
this.route("cat");
this.route("foto");
});
这是Postroute:
and this is the Postroute:
// GET POST JSON
App.PostRoute = Ember.Route.extend({
model: function(params) {
return Ember.$.getJSON('http://www.wilhelminaschool.eu/?json=get_post&post_id='+params.post_id);
}
});
但是我发现路由未找到错误的帖子,帖子列表工作。我在做错什么?
but i get an route not found error for the post, the posts list works. What i am doing wrong?
错误:
错误:断言失败:没有找到路线帖/ 11330
error:Error: Assertion Failed: The route post/11330 was not found
直播:
推荐答案
每个帖子都链接到 app2 /#post /:post_id
ie app2 /#post / 11330
,但由于 post
在帖子
的资源中定义了路径 /:post_id
链接应该是 app2 /#/ posts /:post_id
ie app2 /#/ posts / 11330
Each one of the posts links to app2/#post/:post_id
i.e. app2/#post/11330
, but since the post
resource has been defined within the resource of posts
with a path of /:post_id
the links should be app2/#/posts/:post_id
i.e. app2/#/posts/11330
例如
这篇关于找不到Ember路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!