如何使用铁流星与流星的默认路线

how to use iron-meteor along with default routing of meteor

本文关键字:流星 默认路 何使用      更新时间:2023-09-26

当我创建一个新的流星应用程序时,它已经有了一个"/"路由。我已经在这条路线上添加了我的网页。现在,我需要添加一个新的路由"something",所以为此我使用了iron路由器包。但它需要从iron路由器路由默认路由,这需要我对现有代码进行大量更改。有没有一种方法可以只对特定的路由使用iron路由器,并保持默认路由不变?

您的路由器.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>