流星路由器布局和产量未显示

时间:2015-10-01 08:15:14

标签: javascript meteor iron-router

我对Iron:路由器包有问题。

我尝试使用此代码呈现内容。

Router.route('/',{
 name: 'tagesansicht',
 action: function () {
  this.render('page_day');
  this.layout('layout');
},
data: function () {
},
waitOn: function () {
},
});

page_day.html:

<template name="page_day">
    <div class="head">
        <div class="inner">
            Example
        </div>
    </div>
</template>

和Layout.html:

<template name="layout">
    <nav>
        {{> navigation}}
    </nav>
    <div class="content">
        {{> yield}}
    </div>
</template>

所以现在我不知道为什么代码不会在主页上显示任何内容。 我说路径是&#34; /&#34;渲染page_day.html,布局是layout.html,但为什么我没有看到任何东西?

编辑:

我在控制台中收到此错误

Exception in callback of async function: MiddlewareStack.prototype.concat@http://localhost:3000/packages/iron_middleware-stack.js?ff70621b6c5f6a406edc60600c4b76126dae21d6:303:7
RouteController.prototype._runRoute@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:542:11
Route.prototype.dispatch@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:856:10
Route/route@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:713:5
boundNext@http://localhost:3000/packages/iron_middleware-stack.js?ff70621b6c5f6a406edc60600c4b76126dae21d6:425:16
Meteor.bindEnvironment/<@http://localhost:3000/packages/meteor.js?9730f4ff059088b3f7f14c0672d155218a1802d4:999:17
dispatch@http://localhost:3000/packages/iron_middleware-stack.js?ff70621b6c5f6a406edc60600c4b76126dae21d6:449:3
RouteController.prototype.dispatch/</<@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:393:7
Tracker.Computation.prototype._compute@http://localhost:3000/packages/tracker.js?7776276660c988c38fed448d8262b925dffb5bc3:349:5
Tracker.Computation@http://localhost:3000/packages/tracker.js?7776276660c988c38fed448d8262b925dffb5bc3:237:5
Tracker.autorun@http://localhost:3000/packages/tracker.js?7776276660c988c38fed448d8262b925dffb5bc3:588:11
RouteController.prototype.dispatch/<@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:391:5
Tracker.nonreactive@http://localhost:3000/packages/tracker.js?7776276660c988c38fed448d8262b925dffb5bc3:615:12
RouteController.prototype.dispatch@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:390:3
Router.prototype.dispatch@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:1700:3
onLocationChange@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:1784:20
Tracker.Computation.prototype._compute@http://localhost:3000/packages/tracker.js?7776276660c988c38fed448d8262b925dffb5bc3:349:5
Tracker.Computation@http://localhost:3000/packages/tracker.js?7776276660c988c38fed448d8262b925dffb5bc3:237:5
Tracker.autorun@http://localhost:3000/packages/tracker.js?7776276660c988c38fed448d8262b925dffb5bc3:588:11
Router.prototype.start@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:1777:31
Router/</<@http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:980:9
.withValue@http://localhost:3000/packages/meteor.js?9730f4ff059088b3f7f14c0672d155218a1802d4:971:17
withoutInvocation/<@http://localhost:3000/packages/meteor.js?9730f4ff059088b3f7f14c0672d155218a1802d4:428:26
Meteor.bindEnvironment/<@http://localhost:3000/packages/meteor.js?9730f4ff059088b3f7f14c0672d155218a1802d4:999:17
onGlobalMessage@http://localhost:3000/packages/meteor.js?9730f4ff059088b3f7f14c0672d155218a1802d4:365:11

2 个答案:

答案 0 :(得分:0)

在控制台中,键入 meteor add ejson

答案 1 :(得分:0)

崩溃是因为您声明要呈现{{> navigation}}模板。但是这个模板不存在。

要测试此功能,请注释掉此模板,如下所示。

    <template name="page_day">
        <div class="head">
            <div class="inner">
                Example
            </div>
        </div>
    </template>



    <template name="layout">
        <nav>
            <!-- {{> navigation}} -->
        </nav>
        <div class="content">
            {{> yield}}
        </div>
    </template>