1
不能設法制定的路線,以顯示單篇文章與flowrouter和流星火焰..流星流量路由器設置site.com/singlePostPage
這是我到目前爲止,我敢肯定它的大多是錯的!
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路由器混淆了......任何幫助? 謝謝
謝謝,但仍然不會工作...如何發佈功能知道什麼是postId?我沒有把它定義在任何地方......我實際上是從其他地方複製代碼的一部分,使其工作,但我認爲這是我最困惑的部分...謝謝 – Adam
掛起,我正在編輯我的評論,因爲我注意到其他的事情。別擔心,我也有這個問題。稍等一會兒;) – mesosteros
查看更新。 – mesosteros