在Iron-Router出现之前,在视图/模板之间切换的最佳方式是什么?
现在,我可以href一个新的位置,铁路由器将呈现所需的模板,如下所示:
Router.route('/about', function(){
this.render('about_template',{to:'stuff'});
this.render('personnel_template',{to:'stuff'});
}, {where:'client'});
但如果没有路线,这怎么办呢?我只是在某个操作发生时渲染视图,只需手动更改URL位置吗?
答案 0 :(得分:4)
首先确保您拥有正确的布局模板
<template name="layout">
{{> yield}}
</template>
并像这样配置。
Router.configure({
layoutTemplate: 'layout'
});
现在试试这个。
Router.route('/about', {name: 'about_template'});
并在HTML上调用。
href="{{pathFor 'about_template'}}"