[英]Meteor call method not found
我正在尝试学习流星和咖啡脚本,但是在尝试学习流星方法调用时遇到了麻烦。 我写了以下代码:
客户端/视图/家/ home.html做为
<template name="home">
Welcome to my new meteor app
<input type="button" id='createFile' value="createFile" />
</template>
客户端/视图/家/ home.coffee
Template.home.events
'click #createFile': ->
Meteor.call 'alwaystrue', (error, result) ->
console.log error
console.log result
return
console.log 'You pressed the button' if typeof console isnt 'undefined'
return
服务器/ metodi.coffee
Meteor.methods
alwaystrue: ->
true
单击该按钮时,应使用Meteor.call从客户端调用服务器方法,但它表示未找到alwaystrue方法。
我究竟做错了什么? 为什么我的代码看不到方法?
我从以下样板开始: https : //github.com/Differential/meteor-boilerplate ,在最新的ubuntu(14.04)上使用最新的node.js / meteor。
经过仔细的检查,我没有发现代码有什么问题,这使我相信问题之外的东西是混乱的。 尝试类似的事情:
.coffee
。 如果所有其他方法均失败,则可以创建一个单独的项目,只需添加此代码即可对其进行验证。
样式说明-CoffeeScript具有隐式返回,因此,除非您真的想返回undefined
返回值或要从函数中早返回,否则,不需要Template.home.events
的显式return
语句。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.