javascript - 如何使用 meteor 创建登录系统?

标签 javascript html meteor

我正在努力掌握 meteor ,但我是一个初学者。在这里寻求一个非常基本的帮助。

如何创建 2 个表单(用于登录名和密码输入)和一个使用 Accounts.createUser(options, [callback]) 注册帐户的按钮

我需要了解如何将两种形式与功能联系起来这一非常基本的事情。

编辑:我试过一件事。尽管表现得完全盲目。

    if (Meteor.isClient) {
  Template.login.account = function () {
    if (Meteor.user() == null) {
        return 
            <form id="login">
                <input type="email" id="email" />
                <input type="text" id="logintext" />
                <input type="password" id="password" />
            </form>

        };
    };
  Template.login.events({
    'click input' : Sumbit();
    })
  }

function Sumbit(){
    var login, password, email;
    document.getElementById('email').value = email; 
    document.getElementById('logintext').value = login; 
    document.getElementById('password').value = password; 
    Accounts.createUser(login, email, password)
}

最佳答案

Meteor 已经为您提供了一个相当不错的用户系统:accounts-api

对于登录表单:只需添加 accounts-ui 包(meteor add accounts-ui)并将函数添加到您的模板中:

<template name="main">
    {{loginButtons}} <!--These are your login-buttons -->
</template>

更多信息:here是 accounts-ui 包的文档。

关于javascript - 如何使用 meteor 创建登录系统?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17174256/

相关文章:

javascript - React 中的响应式 D3 图表 : ResizeObserver or the viewBox attribute?

javascript - 使用 JS 创建两个新元素

javascript - 我需要为正在使用的 Accordion 更改颜色

javascript - ACE 编辑器中的自动完成

angular - 在 Angular 4 应用程序中使用 DDP

javascript - 如何在构造函数中将对象添加到数组

javascript - 将 JavaScript 异步和 igraph 代码移植到 R?

javascript - 将文本框保留在屏幕上,货币转换器 - HTML5,Javascript

mongodb - 更新 meteor mongo 中的子文档

javascript - Meteor 中的 ExecCommand 不起作用