-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;
}
}
但它給了一個錯誤。
它給了什麼錯誤? –