【问题标题】:how to use iron-meteor along with default routing of meteor如何使用铁流星和流星的默认路由
【发布时间】:2016-05-19 00:34:38
【问题描述】:
当我创建一个新的流星应用程序时,它已经有一个“/”路由。我已经在这条路线上添加了我的网页。
现在,我需要添加一个新路由“/something”,所以为此我使用了 Iron-router 包。但随后它需要从 Iron-router 路由默认路由,这需要我对现有代码进行大量更改。
有没有办法只对特定路由使用 Iron-router 并保持默认路由不变?
【问题讨论】:
标签:
javascript
meteor
webrtc
iron-router
recordrtc
【解决方案1】:
你的 router.js:
Router.configure({
layoutTemplate:'mainLayoutTemplateName',
loadingTemplate: 'loadingTemplateName'
});
Router.route('/', function() {
this.render('homeTemplateName');
});
Router.route('/anotherRoute', function() {
this.render('anotherTemplateName');
});
编辑:
您还需要在主布局模板中包含 {{> yield}} ,它告诉 Iron-router 在路由中渲染模板的位置。
例如:
<template name="layout">
{{> navigation}}
<div class="content-area">
{{> yield}}
</div>
</template>
<template name="navigation">
This will always be visible in every route according to the template above.
</template>