我注意到Telescope在Meteor.startup函数中写入路由。
Meteor.startup( function () {
Router.route('/comments/:_id', {
name: 'comment_reply',
template: getTemplate('comment_reply'),
controller: CommentPageController,
onAfterAction: function() {
window.queueComments = false;
}
});
});
但我只是在不使用启动函数的情况下编写路径
有没有影响?
答案 0 :(得分:1)
使用Iron-Router时,您应该确保您的路线始终可用。因此,您可以将它们包装到启动函数中或将它们放入/ lib中。 将它们放入/ lib时,路由将可用于两种环境。
最佳实践(根据Discover Meteor)是lib文件夹中名为router.js的文件:
/lib/router.js:
Router.configure({
layoutTemplate: 'layout' //the layoutTemplate for all routes will be 'layout'
//options for every route
});
Router.route('/home', {
//options for the route with the path '/home'
})