Auto destroy keepAlive components when go back
npm install vue-router-keep-alive-helperVue Router Keep-alive Helper is an automatic tool for managing cache pages in the Vue.js project, only one line of configuration code can be used.English | 简体中文
!img
When developing a SPA project of Vue.js with vue-router, is always used to cach pages which are already routed,there are three options to manage the cache tree inside it,
```
include - Only components with matching names will be cached.
exclude - Any component with a matching name will not be cached.
max - The maximum number of component instances to cache.
But these options are only useful in simple situations, otherwise they're useless,such as:
1. destroy current page cache when routing back.
2. cache more than one instances which using same component,and destroy one of them specifically.
1. Recognize pushing going back or replacing automaticallyreplaceStay
2. Destroy current page cache when routing back
3. Always create and cache a new instance,even if this component is already cached
4. Keep the same status after browser refreshing
5. white list allows cache pages when replacing$3
1. `npm i -s vue-router-keep-alive-helper`router-view
2. keep alive the `html`
...
...`
3. create helper after router is createdjavascript`
import createHelper from 'vue-router-keep-alive-helper'
import Vue from 'vue'
const router = new VueRouter({routes})
createHelper({Vue, router});
...
1. replace white list
When switching the tab bar, some tab pages need to be cached,you can set the paths in replaceStay option
`javascript`
createHelper({Vue, router, replaceStay:["/home","/cart","/mine"]});
1. static file
2. Node Project
Twitter zippowxk,Email: zippowangxinkai@gmail.com
wangxinkai 💻 📖 | kamilic 💻 🤔 |