【发布时间】:2014-12-08 14:42:54
【问题描述】:
我玩了一下 Iron Router (Tutorial),但我的模板不能正常工作。
html:
<head>
<title>MY TITLE</title>
</head>
<body>
<h1>Welcome to Meteor!</h1>
</body>
<template name="hello">
This is the hello template.
</template>
<template name="home">
This is the home template.
</template>
JS
Router.map(function(){
this.route('hello');
this.route('home', {path: '/'} );
});
当我启动流星时,它会正确呈现头部中的标题,但它没有显示正文部分中我的模板中的任何内容。 Meteor 没有抛出任何错误,但在浏览器控制台中我有 6 个错误:
[Error] TypeError: undefined is not a function (evaluating 'Template.__create__')
(anonyme Funktion) (iron-dynamic-template.js, line 416)
(anonyme Funktion) (iron-dynamic-template.js, line 433)
global code (iron-dynamic-template.js, line 440)
[Error] TypeError: undefined is not an object (evaluating 'Parent.prototype')
_inherits (meteor.js, line 220)
(anonyme Funktion) (iron-layout.js, line 150)
(anonyme Funktion) (iron-layout.js, line 487)
global code (iron-layout.js, line 494)
[Error] TypeError: undefined is not a constructor (evaluating 'new Iron.Layout({template: this.options.layoutTemplate})')
constructor (iron-router.js, line 1475)
(anonyme Funktion) (iron-router.js, line 1771)
(anonyme Funktion) (iron-router.js, line 1784)
global code (iron-router.js, line 2356)
[Error] TypeError: undefined is not an object (evaluating 'Package['iron-router'].RouteController')
global code (global-imports.js, line 3)
[Error] ReferenceError: Can't find variable: Template
(anonyme Funktion) (template.bla.js, line 2)
global code (template.bla.js, line 20)
[Error] ReferenceError: Can't find variable: Router
(anonyme Funktion) (bla.js, line 1)
global code (bla.js, line 6)
有人知道怎么回事吗?
【问题讨论】:
-
您的错误主要是未定义的符号,您确定您正确添加了
iron:router包吗?meteor add iron:router -
我希望如此。我刚刚通过
npm安装了陨石。在新的流星项目中,我刚刚通过mrt add iron-router安装了 Iron-router。安装日志告诉我一切都很好。 -
你应该做的是:
meteor add iron:router。从您的错误日志看来,您使用的是过时的版本。 -
好的,下次我应该更好地阅读 cmets。现在可以了。谢谢大家!
标签: meteor iron-router