About the max attribute of keep-alive component

This issue has been tracked since 2022-08-29.

Version

2.7.10

Reproduction link

codesandbox.io

Steps to reproduce

  1. Select 111 tab, switch to 222 tab
  2. Repeat the above operation to the 444 tab, switch max to a value such as 1, 2, 3, all caches exist

What is expected?

When the value of the max attribute is less than the number of components currently cached, it is necessary to prune and remove the redundant cache

What is actually happening?

All the caches exist, and the memory is not the max number of caches, but the number controlled by the previous value, only the first one before is eliminated


When the max attribute of the keep-alive component is changed to a value smaller than the previous limit, the previous cache is still retained. When a new cache component comes in, the max attribute is in effect, but it only determines that the limit is exceeded, and The first cache component is deleted, so that there is still the last max number of caches in memory. I think this may be wrong.

I want to dynamically control through the max attribute, the amount I want to cache

max

More Details About Repo
Owner Name vuejs
Repo Name vue
Full Name vuejs/vue
Language TypeScript
Created Date 2013-07-29
Updated Date 2022-10-03
Star Count 199758
Watcher Count 6095
Fork Count 32874
Issue Count 590

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date