select A.col1, A.col2 from A where ...
UNION
select B.col1, B.col2 from B where ...
UNION
...
我尝试在回调中调用createAccount() {
this.afAuth.auth.createUserWithEmailAndPassword(this.email, this.password)
.then(function (message) {
console.log(message);
this.setUserProfile();
})
.catch(function (e) {
console.log(e);
});
}
setUserProfile() {
// some stuff
}`
。问题是当我在回调中设置this.setUserProfile()
时,他们不再能找到这个函数,console.log的运行没有任何问题。
答案 0 :(得分:2)
使用arrow function
来保留上下文。
this.afAuth.auth.createUserWithEmailAndPassword(this.email, this.password)
.then((message) => { // <---- use error function here
console.log(message);
this.setUserProfile();
})
.catch(function (e) { // <---- if you use "this" in error callback, change it to arrow function too
console.log(e);
});