我终于让我的身份验证在创建用户和登录和注销方面发挥作用。但是现在,我想实现一些检查用户是否已经存在于 Firebase 的东西。我查了一下,但似乎找不到具体的答案。
例如,如果我的电子邮件地址是:abc12@gmail.com 并且其他人尝试使用相同的电子邮件地址注册,我如何告诉他们它已被占用?
login(e) {
e.preventDefault();
fire.auth().signInWithEmailAndPassword(this.state.email, this.state.password)
.then((u) => {
}).catch((error) => {
console.log(error);
});
}
signup(e) {
e.preventDefault();
fire.auth().createUserWithEmailAndPassword(this.state.email, this.state.password)
.then((u) => {
}).catch((error) => {
console.log(error);
});
}
Run Code Online (Sandbox Code Playgroud) 我正在阅读如何创建登录表单并遇到此方法:
handleChange(e) {
this.setState({ [e.target.name] : e.target.value });
}
Run Code Online (Sandbox Code Playgroud)
不太确定它的setState部分发生了什么.由于某种原因,阵列括号让我失望.任何人都可以详细说明这种方法在做什么吗?
我希望我的代码显示每个字母频率,但相反,我得到了一个ArrayIndexOutOfBoundsException.我无法发现我做错了什么.
我怎么能纠正这个?
这是我的代码:
public static void solution(String s) {
char[] c = s.toCharArray();
int j = 0, i = 0, counter = 0;
for(i = 0; i < c.length; i++) {
counter = 0;
for(j = 0; j < c.length; j++) {
if(c[j] == c[i]) {
counter++;
}
}
}
System.out.println("The letter " + c[j] + " appears " + counter + " times");
}
public static void main(String args[]) {
String s = "abaababcdelkm";
solution(s);
}
Run Code Online (Sandbox Code Playgroud)