Meteor 路由器仅呈现某些模板
我的布局有两个容器1)productView和2)calendarView。我的路由器配置如下:Meteor 路由器仅呈现某些模板,meteor,iron-router,Meteor,Iron Router,我的布局有两个容器1)productView和2)calendarView。我的路由器配置如下: this.route('productDetail', { layout: 'main', path: '/products/:_id', waitnOn: function(){...}, data: function(){...}, yieldTemplates: { 'calendarView: { to: calendar }
this.route('productDetail', {
layout: 'main',
path: '/products/:_id',
waitnOn: function(){...},
data: function(){...},
yieldTemplates: {
'calendarView: { to: calendar }
}
});
现在我想实现的是,每当路由更改时(例如,从“products/1”更改为“products/2”),只重新呈现productView,而calendarView什么也不做。现在,每次调用“productDetail/:id”路由时,都会调用“calendarView”函数“Template.calendarView.rendered”,并重新呈现模板。我的“主”模板如下所示:
<template name="main">
<div>
{{yield}}
</div>
<div>
{{yield 'calendar'}}
</div>
</template>
{{yield}}
{{yield'calendar'}}
有没有办法告诉路由器只渲染某些模板?还是有更好的解决方案?
非常感谢您的帮助。您使用路由器查看日历有什么原因吗? 我认为一个解决方案可能是不将路由器用于日历视图
<template name="main">
<div>
{{yield}}
</div>
<div>
{{>calendar}}
</div>
</template>
{{yield}}
{{>日历}
谢谢,这是一个很好的观点,但问题仍然存在。它仍然会重新呈现这两个模板…您是否检查了日历模板读取的会话变量是否都不是由产品模板重新呈现所涉及的代码设置的?另一个优点是。但与此同时,我使用一个非常简单的测试设置,没有依赖项和会话变量,并且体验到了相同的行为。