0

我想(出于好奇)在尝试使用 Meteor 应用程序时查看我的 userId。我正在尝试以这种方式显示它:

HTML:

<body>
. . .
<div class="container">
   {{> userIdTemplate}}
   {{> postTravelWizard}}
</div>

</body>

<template name="userIdTemplate">
  {{getUserId}}
</template>

Javascript:

Template.userIdTemplate.helpers({
     getUserId: function () {
       return Meteor.userId;
     }
   });

单步浏览 CDT 中的 .js,我看到 Meteor.userId 的值是“未定义”。我没有经过身份验证 - 只需运行仍然安装了不安全包的应用程序。这就是 userId 未定义的原因吗?

4

1 回答 1

2

null根据文档,在您登录之前,Meteor.userId() 和 Meteor.user() 都将返回。此外,您的代码有错字,Meteor.userId. 应该是Meteor.userId()(注意函数调用)。

于 2015-09-11T15:36:25.620 回答