2016-04-27 88 views
0

後登錄用戶細節沒有,如果我使用登錄用戶列表未在流星中顯示?

Meteor.userId(); 

其顯示的用戶ID 但showing.But如果我用

Meteor.user(); 

其表現undefined.Why會這樣呢?

+1

你是從模板內還是手動登錄到Web控制檯?如果它是前者,那麼顯示上下文會很有幫助。 –

回答

0

Meteor.userId()已經被設置好了,Meteor.user()在頁面加載時沒有滿載。你需要的是將其包裝在

Tracker.autorun(() => { 
    const currentUser = Meteor.user() 
    ... code that needs the current user. 
})