簡體   English   中英

嘗試檢查用戶登錄狀態時,Meteor.user()為null

[英]Meteor.user() is null when trying to check user login status

我試圖將其他一些用戶的個人資料頁面顯示給未登錄和已登錄的用戶。 問題是,每當我檢查

if(Meteor.user() === me)

Meteor.user()返回null ,由於沒有人登錄,代碼崩潰。如何檢查是否有登錄用戶?

試試這個,讓我知道:

if (Meteor.user()) {
    // code for login user
} else {
    // code for non-login user
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM