我正在关注这个流星聊天教程,我已经完成了一半,老师完成了一段代码并在浏览器的控制台中检查它并说“没有错误”很好,但我在同一点上遇到了错误。关于我为什么会收到此错误的任何帮助都会很棒。
文件.js
Message = new Meteor.Collection('messages');
if (Meteor.is_client){
Template.messages.messages = function () {
return Messages.find({}, { sort: {time: -1} });
};
}
文件.html
<head>
<title>tutorial</title>
</head>
<body>
{{> entry}}
{{> messages}}
</body>
<template name="entry">
<p>
<input type="text" id="name" placeholder="your name">
<input type="text" id="messageBox" placeholder="your message"></p>
</template>
<template name="messages">
{{#each messages}}
{{> message}} <!--echo of message template-->
{{/each}}
</template>
<template name="message">
<p><strong>{{name}}:</strong>{{message}}</p>
</template>
错误
Uncaught ReferenceError: Messages is not defined
更新
执行以下消息 = return ... 给我下面的输出
Your app is crashing. Here's the latest log.
app/tutorial.js:5
message = return Messages.find({}, { sort: {time: -1} });
^^^^^^
SyntaxError: Unexpected token return
at /Users/anderskitson/Sites/tutorial/.meteor/local/build/server/server.js:113:21
at Array.forEach (native)
at Function._.each._.forEach (/usr/local/meteor/lib/node_modules/underscore/underscore.js:79:11)
at run (/Users/anderskitson/Sites/tutorial/.meteor/local/build/server/server.js:99:7)
Exited with code: 1
Your application is crashing. Waiting for file change.