【发布时间】:2016-01-26 04:20:53
【问题描述】:
我不知道为什么,但是我的布局被渲染了两次。
这是我的 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({});
}
});
【问题讨论】:
标签: layout meteor routing routes flow-router