我尝试在这样的函数中使用setRoot
ionic
导航控制器:
async login(userx: User1){
// push another page on to the navigation stack
// causing the nav controller to transition to the new page
// optional data can also be passed to the pushed page.
/**/
if(!userx.email || !userx.password) {
alert("You need to enter an email and password");
}
else if(this.stylist && this.type == 'user') {
alert("You do not have a stylist account, you can add one using the signup page");
}
else if(this.users && this.type == 'stylist') {
alert("You do not have a user account, you can add one using the signup page");
}
else if(!this.users && !this.stylist) {
alert('You need to select "Hair Stylist" or "User"');
}
else {
this.afAuth.auth.signInWithEmailAndPassword(userx.email, userx.password).then((data) => {
console.log(data);
if(data.email && data.uid) {
if(this.stylist) {
this.storage.set('type', 'user/stylist/stylist');
this.storage.set('loggedin', true);
this.navCtrl.setRoot(FeedStylist);
}
else {
this.storage.set('type', 'user/stylist/user');
this.storage.set('loggedin', true);
this.navCtrl.setRoot(FeedUser);
}
}
}).catch((e) => {alert("The username or password is incorrect")});
}
}
它可以工作但是还有一个弹出运行时错误,上面写着:
Uncaught (in promise): navigation stack needs at least one root page
。
我不明白为什么它会在我设置root的命令上说这个。任何帮助将不胜感激。