Meteor:Uncaught ReferenceError:未定义帐户

SBD*_*SBD 4 javascript meteor

我正在学习关于学习MeteorJS的教程,但是在调用'Accounts'对象方法'createUser'时我遇到了这个奇怪的错误:

Meteor:  Uncaught ReferenceError: Accounts is not defined
Run Code Online (Sandbox Code Playgroud)

我查阅了文档,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
            }

        });

    },

  });
}
Run Code Online (Sandbox Code Playgroud)

Dav*_*don 8

可能是其中一个帐户包未添加到您的项目中.尝试:

$ meteor add accounts-password
Run Code Online (Sandbox Code Playgroud)