我正在使用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>对于我的软件包,我最初只是尝试安装熨斗:路由器插件。它似乎添加了铁:核心,铁:动态-模板,铁:布局。此后,我又分别添加了每个图书馆:
> 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...发布于 2014-10-03 02:09:05
尝试将您的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"
});您也可以去掉空的主体,并且FYI您不需要手动添加iron:router依赖关系:这就是包系统首先要做的事情:)
https://stackoverflow.com/questions/26172288
复制相似问题