3
我不知道爲什麼,但我的佈局渲染了兩次。流星路由器佈局渲染兩次
這裏是我的index.html:
<head>
<title>title</title>
</head>
<body>
{{>layout}}
</body>
這裏是我的佈局:
<template name="layout">
{{#if canShow}}
{{>Template.dynamic template=content}}
{{else}}
{{> loginButtons}}
{{/if}}
</template>
所以在這裏沒有我的路由模板顯示只是一個時間。
這裏是我的路線:
FlowRouter.route('/', {
action() {
BlazeLayout.render("layout", {
content: "home"
});
}
});
但隨着這條路線我的模板是顯示第二次。
這是我的傭工,我認爲這與這個問題無關,但我們永遠不知道。
Template.home.onCreated(function() {
this.autorun(() => {
this.subscribe('post');
});
});
Template.layout.helpers({
canShow() {
return !!Meteor.user();
}
});
Template.home.helpers({
cats() {
return Posts.find({});
}
});