已解决:每次用户进入页面时调用数据(基于选项卡的路由)

huangapple go评论56阅读模式
英文:

SOLVED Call data every time that user enters in a page (tab based routing)

问题

我正在开发一个基于标签导航的应用程序。
ionic + stencil + typescript
我想在用户进入页面时每次进行API调用,但当用户更改选项卡页面时,页面不会重新加载,因为有缓存。是否有一个事件可以监听以执行此操作?我需要在用户进入选项卡页面时获取新的API数据。

解决方案:
在我想每次用户进入页面时调用API的地方,使用以下代码:

@Listen('ionViewWillEnter')
listenIon() {
    this.userData = undefined;
    loadUserData(this.userId);
}
英文:

I’m developing an app based on tab navigation.
ionic + stencil + typescript
I would like to make my api calls everytime that the user enters on a page but the page don’t recharge when user change tab page because of caching. there is an event that I can listen to do this operation? I need to have fresh data from api every time the user enters in tab pages.

Solution:
In the pare where I want to call the api each time the user enters the page, this code

@Listen('ionViewWillEnter')
listenIon() {
    this.userData = undefined;
    loadUserData(this.userId);
}

答案1

得分: 1

你好,这会帮助你。

ionic页面生命周期

我主要在Angular中使用"ionViewWillEnter"来在页面视图时执行某些操作。它每次都会运行。

干杯。

英文:

Hi This will help you.

ionic Page lifecycle.

I'm mostly using in angular "ionViewWillEnter" to do something when page view. It runs every time.

Cheers.

huangapple
  • 本文由 发表于 2023年7月13日 22:48:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76680740.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定