流星 - 在铁路由器之前

问题描述:

在铁路由器出现之前,在视图/模板之间切换的最佳方式是什么?流星 - 在铁路由器之前

现在,我可以HREF新的位置和铁的路由器将呈现所需的模板,像这样:

Router.route('/about', function(){ 
    this.render('about_template',{to:'stuff'}); 
    this.render('personnel_template',{to:'stuff'}); 
}, {where:'client'}); 

这是怎么回事成就没有路线?当某个动作发生时,我只是呈现视图,只是手动更改URL位置?

首先要确保你有正确的布局模板

<template name="layout"> 
{{> yield}} 
</template> 

和配置是这样的。

Router.configure({ 
    layoutTemplate: 'layout' 
}); 

现在试试这个。

Router.route('/about', {name: 'about_template'}); 

并且在HTML上调用这个。

href="{{pathFor 'about_template'}}" 
+0

我不遵循你的代码。现在,我的#about和#contact路线什么都不做。所以当我点击导航栏项目时URL发生了变化,但没有任何反应。如何将事件(如切换模板)链接到这些URL更改?例如, – 2015-02-06 07:24:53

+0

如何在铁路由器功能之外调用“this.render()”?对? – 2015-02-06 07:29:10

+0

Router.go('/ path')似乎是一个服务器路由而不是客户端 – 2015-02-06 08:16:56