在指南中,我可以看到两种方法来定义资源的路径,我想知道我应该使用的是什么,为什么?
在这里找到:http://emberjs.com/guides/routing/defining-your-routes/
App.Router.map(function() {
this.resource('posts');
this.resource('post', { path: '/posts/:post_id' });
});
Run Code Online (Sandbox Code Playgroud)
在此处找到:http://emberjs.com/guides/templates/links/
App.Router.map(function() {
this.resource("posts", function(){
this.route("post", { path: "/:post_id" });
});
});
Run Code Online (Sandbox Code Playgroud)
我发现很奇怪有定义2个资源,posts并且post,当它实际上只是一个Post资源.
我相信当你这样做的时候
App.Router.map(function() {
this.resource("posts", function(){
this.route("post", { path: "/:post_id" });
});
});
Run Code Online (Sandbox Code Playgroud)
它在帖子模板的{{outlet}}内呈现帖子模板.
当你这样做的时候
App.Router.map(function() {
this.resource('posts');
this.resource('post', { path: '/posts/:post_id' });
});
Run Code Online (Sandbox Code Playgroud)
访问/ posts /:post_id时,帖子模板不会呈现
| 归档时间: |
|
| 查看次数: |
1174 次 |
| 最近记录: |