【发布时间】:2016-12-04 06:27:36
【问题描述】:
来自 firebase 3 文档 https://firebase.google.com/docs/auth/web/manage-users#get_the_currently_signed-in_user
的代码 firebase.auth().onAuthStateChanged(function(user){
if (user) {
// If there's a user take him to the home page.
this.rootPage = HomePage;
} else {
// If there's no user logged in send him to the LoginPage
this.rootPage = LoginPage;
}
});
观察者中的user参数如何设置,上面的代码和下面的代码有什么不同?
教程代码@http://javebratt.com/firebase-3-email-auth/
firebase.auth().onAuthStateChanged((user) => {
if (user) {
// If there's a user take him to the home page.
this.rootPage = HomePage;
} else {
// If there's no user logged in send him to the LoginPage
this.rootPage = LoginPage;
}
});
我问的原因是,我浏览了 ionic 2 和 firebase 3 的教程,firebase.auth().onAuthStateChanged() 的实现明显不同于 firebase 3 官方文档中的内容
【问题讨论】:
标签: typescript ionic-framework firebase ionic2 firebase-authentication