-1
我正在使用ionic2。 我有几页和流 - P1 - > P2 - > P3。防止返回页面按钮,Ionic2在特定条件下
我想在P3上使用ionViewCanLeave()
,这样如果某些条件不符合,它应该在用户按下后退按钮时发出警报。
this.navCtrl.pop()
.catch(() => {
console.log('should I stay or should I go now');
});
ionViewCanLeave(): boolean{
// here we can either return true or false
// depending on if we want to leave this view
let percentMarks = Math.floor((this.totalCorrectAnswers/this.questionSetChosen.length) * 100);
if(percentMarks > 0){
return true;
} else {
return false;
}
}
但它给了一个错误。
它给了什么错误? –