[英]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.