电子邮件地址格式错误 firebase vue.js

Posted

技术标签:

【中文标题】电子邮件地址格式错误 firebase vue.js【英文标题】:The email address is badly formatted firebase vue.js 【发布时间】:2018-09-24 12:38:31 【问题描述】:

收到错误“电子邮件地址格式错误。”尝试将 Vue.js 与 firebase 一起使用来创建登录页面时。

这是我的代码:

<template>
    <div class = "sign-up">
        <p> Let's create a new account</p>
        <input type="email" v-model="email" placeholder="Email"> <br>
        <input type="password" v-model="password" placeholder="Password"> <br>
        <button v-on:click="signUp">Sign Up</button>
        <br>

    </div>

</template>


<script> 

import firebase from 'firebase'

      export default 
    name:'Signup',
    data: function() 
      return 
        email: '',
        password: '',
      
    ,
    methods: 
        signUp: function() 

            firebase.auth().createUserWithEmailAndPassword(this.email, this.password).then(

                function (user) 
                    alert('Your account has been created')
                ,
                function(error) 

                   var errorCode = error.code;
                   var errorMessage = error.message;

                   if (errorCode == 'auth/weak-password') 
                       alert('The password is too weak.');
                   else 
                       alert(errorMessage);
                      
                    console.log(error);

                 );
        

    

  



</script>

我确实确保我已在 firebase 控制台上启用了身份验证部分。

不知道为什么还是会出现这个错误

请帮忙

【问题讨论】:

【参考方案1】:

感谢上帝,我解决了。

问题通过添加解决

 firebase.initializeApp(config);

紧接着

import firebase from 'firebase'

因为我已经在其他文件中初始化了 Firebase

这个问题可能是由于 javascript 异步加载造成的。

【讨论】:

【参考方案2】:

这很好用。我厌倦了解决你的问题。我带来了官方的 Firebase 身份验证样本。您的用户未定义,在导入时您必须使用 来防止 .auth() 错误。

       <template>
        <div class = "sign-up">
            <p> Let's create a new account</p>
            <input type="email" v-model="email" placeholder="Email"> 
            <input type="password" v-model="password" placeholder="Password">
            <button v-on:click="signUp">Sign Up</button>
    
        </div>
    </template>
    
    
    <script> 
    
    import fb from '../firebase';
    
          export default 
        name:'Signup',
        data() 
          return 
            email: "",
            password: "",
          
        ,
        methods: 
            signUp: function() 
                fb.auth().createUserWithEmailAndPassword(this.email, this.password)
                        .catch(function(error) 
                    // Handle Errors here.
                    var errorCode = error.code;
                    var errorMessage = error.message;
                    if (errorCode == 'auth/weak-password') 
                        alert('The password is too weak.');
                     else 
                        alert(errorMessage);
                    
                    console.log(error);
                    );    
            
    
        
    
      
    
    
    
    </script>

【讨论】:

以上是关于电子邮件地址格式错误 firebase vue.js的主要内容,如果未能解决你的问题,请参考以下文章

该电子邮件地址已被另一个帐户使用(使用电子邮件/密码 Firebase 进行身份验证)

Expo App 中的 Firebase 无密码电子邮件身份验证错误

如何在firebase auth中更改电子邮件?

Firebase错误:W / BiChannelGoogleApi:[FirebaseAuth:] getGoogleApiForMethod()返回Gms

Firebase:是不是可以从用户的电子邮件地址发送电子邮件? [关闭]

通过 Firebase 函数发送电子邮件时出现 Firebase SendGrid 错误 - 错误:错误请求