2012-06-23 95 views
1

這些都是我在正在執行步驟:流星創建的HelloWorld

# meteor create helloworld 

# cd helloworld 

# meteor 

終端顯示Running on: http://localhost:3000/

我將瀏覽器指向http://localhost:3000/

一切都在瀏覽器看起來不錯,我看到的Hello World !。我點擊[點擊]按鈕。沒有任何反應,瀏覽器沒有提示。我切換到終端預計看到您按下按鈕,但我看到的只是Running on: http://localhost:3000/我看不到您在客戶端或服務器的任何位置按下按鈕

所以在helloworld.js,下面的代碼段應該做什麼?

Template.hello.events = { 
    'click input' : function() { 
     // template data, if any, is available in 'this' 
     if (typeof console !== 'undefined') 
     console.log("You pressed the button"); 
    } 
    }; 
} 

我最好的猜測是在該行Running on: http://localhost:3000/低於端你按下此按鈕會出現每次我按一下按鈕,但沒有任何反應。

回答

2

檢查瀏覽器的控制檯。如果您使用Chrome通過工具 - > Javascript控制檯使用Chrome訪問控制檯。您會看到諸如元素,資源等標籤......轉到最後一個「控制檯」。您也可以使用Ctrl + Shift + J來訪問Javascript控制檯。

1

望着解釋發現於:Extremely Gentle Introduction to Meteor.js

它看起來像客戶端的側實際執行的代碼的一部分,並會在瀏覽器的JavaScript控制檯顯示出來,而不是在服務器上。

注重事實,你的代碼被包裹在:

if (Meteor.is_client) { 
    ... 
}