
Security News
CISA Rebuffs Funding Concerns as CVE Foundation Draws Criticism
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
keep-alive-vue3
Advanced tools
Extend vue3 keep-alive and router-view, add the function of automatically judging whether to use the cache.
Extend vue3 keep-alive and router-view, add the function of automatically judging whether to use the cache.
You can use vite-app-pro cli to create template project,keep-alive-vue3 was built in project,convenient experience and use。
Support for vue2 Click here
If the page uses keep-alive and router-view, the advantage is that the operation state of the previous step is quickly restored when the next page operation returns, and this experience is very good.
But it also brings problems.
When the user enters the page from the navigation menu or breadcrumb, a brand new page is needed, but the cached page is actually used, and this result is not what we want.
keep-alive-vue3 solves this problem.
It uses the cache when you operate router.back and router.go to return the page by default, and router.push and router.replace do not use the cache by default.
npm i keep-alive-vue3
import KeepAliveVue3 from 'keep-alive-vue3';
Vue.use(KeepAliveVue3);
keep-alive-vue3 encapsulates keep-alive and router-view internally,
so you only need to write the keep-alive-vue3 component element.
The cache attribute is used to cache the use of page caching.
<-- Recommend -->
<keep-alive-vue3 :cache="$route.meta.cache" />
<-- Use cache for items with tab manager -->
<keep-alive-vue3
:cache="!$route.meta || !$route.meta.noCache"
:defaultCache="true" />
property | description | type | option | default |
---|---|---|---|---|
cache | whether to cache page | Boolean | true/false | false |
defaultCache | router.push、router.replace and router.go(value is greater than 0) parameter cache will use the value | Boolean | true/false | false |
name | router-view name | String | - | - |
include | only components with matching names will be cached | RegExp | - | - |
exclude | any component whose name matches will not be cached | RegExp | - | - |
max | maximum number of component instances that can be cached | Number | - | - |
The page displayed by the push/replace interface does not use the cache function by default. If you need to use it, configure cache to true Note that defaultCache can change the default cache
// disable cache
router.push({
name: 'list',
});
router.replace({
name: 'list',
});
// use cache
router.push({
name: 'list',
cache: true
});
router.replace({
name: 'list',
cache: true
});
The page displayed by the back/forward/go interface uses the cache function by default. If not use cached page, configure cache to false
// defaut use cache
router.back();
router.forward();
router.go(1);
// disable cache
router.back({cache: false});
router.forward({cache: false});
router.go(1, {cache: false});
keep-alive-vue3 cache | router cache | Whether to use cache |
---|---|---|
true | true | Yes |
true | false | Not |
false | true | Not |
false | false | Not |
The page cache takes effect when both cache values are true. None of the others use cached pages. |
FAQs
Extend vue3 keep-alive and router-view, add the function of automatically judging whether to use the cache.
The npm package keep-alive-vue3 receives a total of 10 weekly downloads. As such, keep-alive-vue3 popularity was classified as not popular.
We found that keep-alive-vue3 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.
Product
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.