Html 尝试了所有操作,但仍然发生此错误-发生了网络错误(例如超时、连接中断或无法访问主机)
LoginPage.htmlHtml 尝试了所有操作,但仍然发生此错误-发生了网络错误(例如超时、连接中断或无法访问主机),html,angularjs,firebase,Html,Angularjs,Firebase,LoginPage.html <div layout="column" ng-app="HelpingHand" ng-controller="login" layout- fill> <md-content> < div layout="column" > <md-input-container class="md-block"> <input ng-model="email" type="
<div layout="column" ng-app="HelpingHand" ng-controller="login" layout-
fill>
<md-content>
< div layout="column" >
<md-input-container class="md-block">
<input ng-model="email" type="email" placeholder="Email (required)"
ng-required="true">
</md-input-container>
<md-input-container class="md-icon-float md-block">
<label>Password</label>
<input ng-model="password" type="text">
</md-input-container>
<md-button ng-href="login.html" ng-click="emaillogin()" class="md-
raised md-warn">Login</md-button>
<md-button class="md-raised md-primary">Cancel</md-button>
</div>
错误消息返回以下错误-发生网络错误(如超时、连接中断或主机无法访问)
错误代码返回以下错误-身份验证/网络请求失败
我对这个代码犯了什么错误?修复了这个问题。。只是弄乱了我的项目id对我来说,问题是在收到回复之前,我试图使用
windows.location=“url”
从页面导航
这似乎是回应的时间问题。下面在if(true)
语句中注释掉了这个令人不快的问题
function toggleSignIn() {
if (firebase.auth().currentUser) {
// [START signout]
firebase.auth().signOut();
// [END signout]
} else {
var email = document.getElementById('email').value;
var password = document.getElementById('password').value;
if (email.length < 4) {
alert('Please enter an email address.');
return;
}
if (password.length < 4) {
alert('Please enter a password.');
return;
}
// Sign in with email and pass.
// [START authwithemail]
firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// [START_EXCLUDE]
if (errorCode === 'auth/wrong-password') {
alert('Wrong password.');
} else {
alert(errorMessage);
}
console.log(error);
document.getElementById('quickstart-sign-in').disabled = false;
// [END_EXCLUDE]
});
// [END authwithemail]
// clear user / pass
document.getElementById('email').value = "";
document.getElementById('password').value = "";
/*
if (true) {
window.location = "{URL}";
}
*/
}
document.getElementById('quickstart-sign-in').disabled = true;
}
function toggleSignIn(){
if(firebase.auth().currentUser){
//[开始注销]
firebase.auth().signOut();
//[结束签出]
}否则{
var email=document.getElementById('email')。值;
var password=document.getElementById('password')。值;
如果(电子邮件长度<4){
警报('请输入电子邮件地址');
返回;
}
如果(密码长度<4){
警报('请输入密码');
返回;
}
//使用电子邮件登录并传递。
//[启动authwithemail]
firebase.auth(){
//在这里处理错误。
var errorCode=error.code;
var errorMessage=error.message;
//[开始时不包括]
如果(错误代码==='auth/错误密码'){
警报(“密码错误”);
}否则{
警报(错误消息);
}
console.log(错误);
document.getElementById('quickstart-sign-in')。disabled=false;
//[完]
});
//[结束电子邮件]
//清除用户/通行证
document.getElementById('email')。value=“”;
document.getElementById('password')。value=“”;
/*
如果(真){
window.location=“{URL}”;
}
*/
}
document.getElementById('quickstart-sign-in')。disabled=true;
}
为了修复并回到我想要的状态,我添加了以下内容:var timer=setTimeout(function(){window.location='url'},3000);
function toggleSignIn() {
if (firebase.auth().currentUser) {
// [START signout]
firebase.auth().signOut();
// [END signout]
} else {
var email = document.getElementById('email').value;
var password = document.getElementById('password').value;
if (email.length < 4) {
alert('Please enter an email address.');
return;
}
if (password.length < 4) {
alert('Please enter a password.');
return;
}
// Sign in with email and pass.
// [START authwithemail]
firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// [START_EXCLUDE]
if (errorCode === 'auth/wrong-password') {
alert('Wrong password.');
} else {
alert(errorMessage);
}
console.log(error);
document.getElementById('quickstart-sign-in').disabled = false;
// [END_EXCLUDE]
});
// [END authwithemail]
// clear user / pass
document.getElementById('email').value = "";
document.getElementById('password').value = "";
/*
if (true) {
window.location = "{URL}";
}
*/
}
document.getElementById('quickstart-sign-in').disabled = true;
}