我无法创建路线以在 Meteor 中使用 flowrouter 和 blaze 显示单个帖子。
这是我到目前为止所拥有的,我相信它大部分是错误的!
publications.js
Meteor.publish('singlePost', function (postId) {
return Posts.find({ _id: postId });
});
Router.js
FlowRouter.route("/posts/:_id", {
name: "postPage",
subscriptions: function (params, queryParams) {
this.register('postPage', Meteor.subscribe('singlePost'));
},
action: function(params, queryParams) {
BlazeLayout.render("nav", {yield: "postPage"} )
}
});
singlePost.JS
Template.postPage.helpers({
thisPost: function(){
return Posts.findOne();
}
});
singlePost.html
<template name="postPage">
{{#with thisPost}}
<li>{{title}}</li>
{{/with}}
</template>
我以前用 Iron 路由器做,但现在对 Flow 路由器感到困惑。