2015-02-10 39 views
2

我下面就学习MeteorJS的教程,但是我得到调用“帐户”对象的方法“的createUser”当这个奇怪的错误:流星:未捕获的ReferenceError:应收没有定义

Meteor: Uncaught ReferenceError: Accounts is not defined 

我抬头文档和Meteor提供了一个在您的项目中安装Meteor的完整账户系统。 (https://www.meteor.com/accounts)。这个错误的原因是什么?我无法找到答案。

我的代码:

if (Meteor.isClient) { 



Template.login.creatingAccount = function() 
    { 
    return Session.get('creatingAccount'); 

    }, 



Template.login.events({ 


    'click #loginform': function() 
    { 
     Session.set('creatingAccount', false); 
    }, 
    'click #accountform': function() 
    { 
     Session.set('creatingAccount', true); 
    }, 
    'click #createAccount': function(e,t) 
    { 
     //make sure to show the login form 
     Session.set('creatingAccount', false); 
     Accounts.createUser({ 

      username: t.find('#username').value, 
      password: t.find('#password').value, 
      email: t.find('#email').value, 
      profile: { 
       name: t.find("#username").value, 
       email: t.find("#email").value 
      } 

     }); 

    }, 

    }); 
} 

回答

5

这可能是因为该账户包中的一个未添加到您的项目。尝试:

$ meteor add accounts-password 
+1

谢谢,解决了它。我滚动回来,现在我明白发生了什么事。认为账户对象在流星本身是标准的! – Marciano 2015-02-11 10:42:53

0

您很可能没有添加除帐户基础之外的任何内容。这不会为您提供旧式帐户包的功能。您需要添加帐户库,然后再添加验证用户的解决方案之一。有很多选择一些最受欢迎的是:帐户密码如上面说的与账户facebook,accounts-twitter和几个第三方软件包如accounts-linkedin https://atmospherejs.com/yefim/accounts-linkedin

相关问题