0

Iron:router パッケージで Meteor を使用しています。基本的なテンプレートをレイアウト テンプレートにレンダリングしようとしていますが、エラーが発生し続けます。

Exception from Tracker recompute function: Error: Couldn't find a template named "/" or "". Are you sure you defined it?

私の「/」ルートには、次のものがあります。

// router.js

Router.configure({
  layout: 'layout'
});

Router.route('/', function () {
  this.render('welcome');
});

私のテンプレートは次のようになります。

<!--main.html -->

<head>
  <title>App</title>
</head>

<body>
</body>

<template name='layout'>
  <div id='container'>
    {{> yield}}
  </div>
</template>

<template name='welcome'>
  <p>Welcome</p>
</template>

私のパッケージでは、最初は iron:router プラグインだけをインストールしようとしました。iron:core、iron:dynamic-templates、iron:layout が追加されたようです。それ以来、各ライブラリを個別に追加しました:

> meteor list
iron:core              0.3.4  Iron namespace and utilities.
iron:dynamic-template  0.4.1  Dynamically create and update templates and the...
iron:layout            0.4.1  Dynamic layouts which enable rendering dynamic ...
iron:router            0.9.4  Routing specifically designed for Meteor
meteor-platform        1.1.1  Include a standard set of Meteor packages in yo...
4

1 に答える 1

1

に変更してみてくださいrouter.js

Router.configure({
  layoutTemplate: 'layout' // layoutTemplate, not layout
});

Router.route('/',{
  // give the the route a name to help it find your welcome template
  // let the default action function render the layout + template for you
  name:"welcome"
});

空の本体も取り除くことができます。参考までに、iron:router依存関係を手動で追加する必要はありません:それがそもそもパッケージシステムの目的です:)

于 2014-10-03T02:09:05.423 に答える