英文:
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
你好,这会帮助你。
我主要在Angular中使用"ionViewWillEnter"来在页面视图时执行某些操作。它每次都会运行。
干杯。
英文:
Hi This will help you.
I'm mostly using in angular "ionViewWillEnter" to do something when page view. It runs every time.
Cheers.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论