0
我正在嘗試學習Meteor和coffeescript,但我在試圖學習流星方法調用時被卡住了。我寫了下面的代碼:未找到流星調用方法
客戶端/視圖/家庭/ 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方法d未找到。
我在做什麼錯?爲什麼我的代碼不能看到方法?
我從這個樣板文件開始:https://github.com/Differential/meteor-boilerplate,在最新的ubuntu(14.04)上提供最新的node.js/meteor。
我在這裏沒有看到任何技術上的錯誤 - 這看起來像是問題之外的東西被搞砸了。例如文件沒有保存,方法文件實際上並沒有在'.coffee'中結束,並且沒有被編譯,方法名拼寫錯誤,等等。 –
我現在會更加努力檢查 – Mascarpone
是的它有效。在不使用樣板的情況下從頭開始重新創建後,我使其工作。我可能認爲這是由於縮進或安裝了一些軟件包造成的。非常感謝您的道義支持,請將您的評論改爲回答,以便我可以將其選爲正確的建議。 – Mascarpone