简体   繁体   English

单击选项卡后离子段无法刷新

[英]ion-segment not refreshing with I click on tab

I have a simple page with "Homes" and "sales data" in a ion-segment. 我有一个简单的页面,其中包含一个离子段中的“房屋”和“销售数据”。

  • The Homes data is refreshed with I click on the Data/Homes segment. 通过单击“数据/房屋”部分来刷新房屋数据。 Back and forth work fine. 来回工作正常。
  • When I click on another tab and come back to the Home tab the Home segment is not refreshed with current or new home data. 当我单击另一个选项卡并返回到“主页”选项卡时,“主页”段不会用当前或新的主页数据刷新。

     <ion-segment [(ngModel)]="currentsegment" color="primary"> <ion-segment-button value="Homes" (ionSelect)="changeTab('Homes')"> Homes </ion-segment-button> <ion-segment-button value="Data" (ionSelect)="changeTab('Data')"> Data </ion-segment-button> </ion-segment> 

anyone have a fix for this issue? 有人有解决此问题的方法吗? Strange caching. 奇怪的缓存。

Aha so I suppose you have a Tabs Layout page. 啊哈,所以我想您有一个“标签布局”页面。

In your ts you can bind to the ionViewWillEnter lifecycle. 在您的ts中,您可以绑定到ionViewWillEnter生命周期。 This will fire, well, when you enter the view so basically every time you come back to the page. 好吧,当您进入视图时,基本上每次您返回页面时都会触发。

ionViewWillEnter() {
  if(this.currentsegment == 'Homes') {
    this.functionThatSetsMyHomeData();
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM