首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法呈现动态模板的流星

无法呈现动态模板的流星
EN

Stack Overflow用户
提问于 2014-10-03 02:03:22
回答 1查看 1K关注 0票数 0

我正在使用Meteor与铁:路由器包。我只是尝试将一个基本模板呈现为布局模板,但始终收到以下错误:

代码语言:javascript
复制
Exception from Tracker recompute function: Error: Couldn't find a template named "/" or "". Are you sure you defined it?

关于我的“/”路线,我有以下内容:

代码语言:javascript
复制
// router.js

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

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

我的模板看起来如下:

代码语言:javascript
复制
<!--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>

对于我的软件包,我最初只是尝试安装熨斗:路由器插件。它似乎添加了铁:核心,铁:动态-模板,铁:布局。此后,我又分别添加了每个图书馆:

代码语言:javascript
复制
> 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...
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-03 02:09:05

尝试将您的router.js修改为:

代码语言:javascript
复制
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"
});

您也可以去掉空的主体,并且FYI您不需要手动添加iron:router依赖关系:这就是包系统首先要做的事情:)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26172288

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档