所以铁路由器github页面说明了这一点:
最新版本:0.8.2
重要提示:请勿从Atmosphere安装0.9.0或0.9.1版本。 这些版本适用于新的Meteor包装系统 可在Meteor v0.9.0中找到。铁路由器0.9.x错误地被释放了 到大气。
当我在项目目录中运行meteor list
时,我得到了这个:
standard-app-packages 1.0.1 Moved to meteor-platform
iron:router 0.9.3 Routing specifically designed for Meteor
d3 1.0.0 Library for manipulating documents based on data
less 1.0.8 The dynamic stylesheet language
accounts-password 1.0.1 Password support for accounts
jquery 1.0.0 Manipulate the DOM using CSS selectors
http 1.0.5 Make HTTP calls to remote servers
meteor --version
向我展示了这一点:
Meteor 0.9.2.2
我安装了铁路由器,根据上面引用的同一个github页面上的说明,如下:
meteor add iron:router
当我运行我的应用程序时,我在浏览器控制台中给出以下错误消息:
No Iron.Layout found so you can't use yield!
我的布局模板如下所示:
<template name='advantage_layout'>
<div id='advantage-nav'>
<div id='user-control'>
<div id='brand-username'>
Advantage: {{username}}
</div>
<div id='user-buttons'>
<button id='settings-button' class='user-button'>Settings</button>
<button id='logout-button' class='user-button'>Logout</button>
</div>
</div>
{{>nav}}
</div>
<div id='advantage-content'>
{{> yield}}
</div>
</template>
我像这样配置路由器:
var mustBeSignedIn = function(pause) {
if (!Meteor.user()) {
// render the login template but keep the url in the browser the same
this.render('login');
// pause this rendering of the rest of the before hooks and the action function
pause();
}
}
// this hook will run on almost all routes
Router.onBeforeAction(mustBeSignedIn, {except: ['login']});
Router.configure({
loadingTemplate: 'loading',
layoutTemplate: 'advantage_layout'
})
Router.map(function() {
this.route('user_settings', {
path: 'user-settings/',
layoutTemplate: 'advantage_layout',
template: 'user_settings',
});
});
帮助。