Vuex存储数据始终驻留在内存中吗?

kkd*_*927 3 vue.js vuex

首先,感谢您对我英语水平差的理解。我想知道Vuex的存储数据是否总是驻留在内存中。

让我举例说明。当进入页面A时,我们从服务器收到一个列表,并将其实现为存储在商店中。这是否意味着当我进入页面A并移至页面B时,即使不使用A的列表也将保留在内存中?

这是否会在大型应用程序中导致内存溢出?

Dec*_*oon 9

The entire page state (including the DOM and Javascript/Vuex data) will remain in memory provided that a full page reload did not occur (which would be the case if you're using vue-router). This is called a Single Page Application (SPA).

在SPA中,您需要确保null在不再需要对大型对象和数组的引用时将其删除(例如,设置为),以便垃圾回收器可以释放内存。

  • 我的问题是,他们为什么不选择本地存储? (3认同)