离子缓存不起作用

编程入门 行业动态 更新时间:2024-10-13 00:34:01
本文介绍了离子缓存不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用Ionic开发应用程序,但缓存无法按预期工作。 每次从 root.home.notifs 切换到 root.home.chats 聊天查看已刷新(其控制器已重新初始化)。

I'm developing an app using Ionic, but caching isn't working as expected. Every time I switch from root.home.notifs to root.home.chats the chats view is refreshed (its controller is reinitialized).

我有2个标签:

<ion-footer-bar> <ion-tabs class="tab-bottom tabs-striped"> <ion-tab icon="ion-ios-chatboxes-outline" ui-sref="root.home.chats"> </ion-tab> <ion-tab icon="ion-ios-heart-outline" ui-sref="root.home.notifs"> </ion-tab> </ion-tabs> </ion-footer-bar>

这些状态(我的控制器为空):

And these states (my controllers are empty):

.state('root.home', { abstract: true, cache : true, url: '/home', templateUrl: 'components/home/templates/home.html' }) .state('root.home.chats', { url: '/chats', cache : true, controller: 'ChatCtrl', templateUrl: 'components/home/templates/home.chats.html' }) .state('root.home.notifs', { url: '/notifs', cache : true, controller: 'NotifCtrl', templateUrl: 'components/home/templates/home.notifs.html' })

每个视图都有 cache-view =true我以这种方式配置了缓存 $ ionicConfigProvider.views.maxCache(100)

Every view has cache-view="true" and I've configured the cache this way $ionicConfigProvider.views.maxCache(100)

注意:我注意到这个错误取决于我首先导航到哪个州。有一个auth系统调用 $ state。$ go('root.home.notifs')。更改此更改会更正哪个视图正确缓存

NOTE: I've noticed that this error depends on which state I navigate to first. There's an auth system that calls $state.$go('root.home.notifs'). Changing this changes which view is cached correctly

有关如何解决此问题的任何提示?

Any tip on how to solve this?

推荐答案

尝试使用它来缓存前向视图 $ ionicConfigProvider.views.forwardCache(true);

Try using this to cache the forward view $ionicConfigProvider.views.forwardCache(true);

更多推荐

离子缓存不起作用

本文发布于:2023-11-26 08:37:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1633397.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓存   离子   不起作用

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!