到目前为止,我一直在寻找各种各样的互联网和Meteor文档,但没有任何东西对我有用.
我正在创建一个帐户
Accounts.createUser({
username: username,
email: email,
password: password
});
Run Code Online (Sandbox Code Playgroud)
我知道这是有效的,因为{{#if currentUser}}它正在发挥作用.
但是,我试图获取当前登录用户的用户名,例如
var username = Meteor.userId();
console.log(username);
var username = Meteor.userId().username;
console.log(username);
Run Code Online (Sandbox Code Playgroud)
但是两者都没有用,当我使用时Meteor.userId()我只是得到一个随机(我猜是加密的)数字和字母串,当我使用Meteor.userId().username它时说它是未定义的.
所有的帮助都是受欢迎的,对不起我可能很糟糕的语法,这里已经很晚了!
Dan*_*scu 10
Meteor.userId()从Mongo.users集合返回用户的_id .这就是为什么它看起来像一个毫无意义的字符串.
你想要的Meteor.user().该文档是你最好的朋友:)
| 归档时间: |
|
| 查看次数: |
27912 次 |
| 最近记录: |