2017-11-18 243 views
-2

现在我有Ionic3,Angular4 Android应用工作。每当我回到上一页时,它都会在Android应用程序中重新加载页面。如何防止这一点。该页面仍然已加载。所以我不想重装一遍又一遍当我们回到上一页时,如何防止重新加载页面?

+0

向我们展示一些代码。重装是什么意思? –

回答

0

使用Push和离子的框架,可以作为新的页面推入和弹出的,对应于历史向前和向后移动一个简单的栈中弹出。

Refer Ionic documentation too

@Component({ 
    template: ` 
    <ion-header> 
    <ion-navbar> 
     <ion-title>Login</ion-title> 
    </ion-navbar> 
    </ion-header> 

    <ion-content> 
    <button (click)="goToOtherPage()"> 
     Go to OtherPage 
    </button> 
    </ion-content>` 
}) 
export class StartPage { 
    constructor(public navCtrl: NavController) {} 

    goToOtherPage() { 
    //push another page onto the history stack 
    //causing the nav controller to animate the new page in 
    this.navCtrl.push(OtherPage); 
    } 
} 

@Component({ 
    template: ` 
    <ion-header> 
    <ion-navbar> 
     <ion-title>Other Page</ion-title> 
    </ion-navbar> 
    </ion-header> 

    <ion-content>I'm the other page!</ion-content>` 
}) 
class OtherPage {} 
0

使用this.navCtrl.push(Page);代替this.navCtrl.setRoot(Page);并记得做

ionViewWillEnter() { 
    this.viewCtrl.showBackButton(true) 
} 

goBackToPreviousPage() { 
    this.navCtrl.pop(); 
} 
相关问题