Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor 流星-铁前路由器_Meteor_Iron Router - Fatal编程技术网

Meteor 流星-铁前路由器

Meteor 流星-铁前路由器,meteor,iron-router,Meteor,Iron Router,在Iron Router出现之前,在视图/模板之间切换的最佳方式是什么 现在,我可以href一个新位置,iron router将呈现所需的模板,如下所示: Router.route('/about', function(){ this.render('about_template',{to:'stuff'}); this.render('personnel_template',{to:'stuff'}); }, {where:'client'}); 但是,没有路线,这是如何实现的呢?我

在Iron Router出现之前,在视图/模板之间切换的最佳方式是什么

现在,我可以href一个新位置,iron router将呈现所需的模板,如下所示:

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.route('/about', {name: 'about_template'});
并在HTML上这样调用

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

首先确保您有正确的布局模板

<template name="layout">
{{> yield}}
</template>
现在试试这个

Router.route('/about', {name: 'about_template'});
并在HTML上这样调用

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

我不遵守你的守则。现在,我的“关于”和“联系路线”没有任何作用。因此,当我单击导航栏项时,URL会发生变化,但什么也没有发生。如何将事件(如切换模板)链接到这些URL更改?例如,如何在iron router函数外部调用“this.render()”?对吗?Router.go(“/path”)似乎是一个服务器路由,而不是客户端路由。这解决了我的问题。调用Router.go('xyz');以及Router.route('/posts/:_id',function(){this.render('Post');},{name:'xyz'});我不遵守你的守则。现在,我的“关于”和“联系路线”没有任何作用。因此,当我单击导航栏项时,URL会发生变化,但什么也没有发生。如何将事件(如切换模板)链接到这些URL更改?例如,如何在iron router函数外部调用“this.render()”?对吗?Router.go(“/path”)似乎是一个服务器路由,而不是客户端路由。这解决了我的问题。调用Router.go('xyz');以及Router.route('/posts/:_id',function(){this.render('Post');},{name:'xyz'});