2014-01-29 41 views
0

當我做了流星用戶不確定

console.log Meteor.user() // on client script, coffeeScript 

我能找到這個標準鉻但不是在所有其他瀏覽器 無法確定是否有什麼我需要做什麼?

+0

你究竟想要做什麼? – fuzz

+0

我想寫一個簡單的if else函數if(Meteor.user()){//做些什麼...}但是Meteor.user()在chrome以外的其他瀏覽器中返回undefined –

+0

只需檢查:您已簽名在其他瀏覽器中,對嗎? –

回答

2

的解決方案是使用deps.autorun

Deps.autorun 
    if Meteor.user() 
    # continue the code here...CoffeeScript 

根據他們的文件:

Deps.autorun允許您運行依賴於反應 數據源的功能,在這樣的方式如果稍後數據 發生更改,該功能將重新運行。