Home > front end >  Vue TAB is closed, how to destroy memory
Vue TAB is closed, how to destroy memory

Time:09-23

Vue TAB closing, destruction of memory

CodePudding user response:

After page is closed if not use the keep alive - vue automatically destroy the component

CodePudding user response:

Use the keep alive

CodePudding user response:

Have a great god knows how to solve

CodePudding user response:

Recently I also useful to this thing, also have to meet you this similar problem, thinking for a long time, without a look at the source level thought of a way, also did not practice, said come out, let's talk about the main idea is to use the component of include attribute, we again vuex maintenance inside an array, each one to cache the page to push a data inside, then close the page each time, both in the hook to the corresponding page is removed from the array, keepalive components include attributes, binding for the array of vuex, should can achieve this effect, temporarily so, for a while to study the keepalive source, see if there are any better way,

CodePudding user response:

I just use the way you said, the memory is not destroyed

CodePudding user response:



Use the keep alive

CodePudding user response:

This counterintuitive, you use the keep alive - was to leave when the page cache, but you want to exit the page again destroy memory,

CodePudding user response:

Try beforeDestory, when executing the lifecycle hooks vue instance from running stage into the destruction stage instance at this time of the data and the methods in the available state,
  • Related