我正在使用离子3,当我使用popToRoot()时,当前页面仍然执行并且不会被破坏。我认为popToRoot()假设在进入根页面时销毁当前页面?这是代码:
ionViewDidLoad() {
this.menuCtrl.swipeEnable(false);
this.navCtrl.swipeBackEnabled = false;
this.loop();
}
loop() {
this.API.doGet(URL)
.then((data) => {
if (data == 'Yes') {
...
}
else {
// Wait on timer and call again - 10 seconds
this.Timeout = setTimeout(() => { this.onLoopTimeout() }, 10000);
}
})
.catch((err) => {
this.errorTimeout = setTimeout(() => { this.loop(); }, 3000);
})
}
onLoopTimeout() {
this.loop();
}
notInRepair() {
// Clear timers
clearTimeout(this.Timeout);
clearTimeout(this.errorTimeout);
// Go back to home page
this.navCtrl.setRoot(ServicesPage);
this.navCtrl.popToRoot();
}
你们知道我在这里做错了吗?