Gathering detailed insights and metrics for vue-router-cache-animate
Gathering detailed insights and metrics for vue-router-cache-animate
npm install vue-router-cache-animate
Typescript
Module System
Node Version
NPM Version
TypeScript (65.42%)
JavaScript (34.58%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
1,442
Last Day
6
Last Week
6
Last Month
13
Last Year
164
1 Stars
10 Commits
1 Watching
2 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
0.0.5
Package Id
vue-router-cache-animate@0.0.5
Unpacked Size
299.19 kB
Size
102.45 kB
File Count
27
NPM Version
6.12.0
Node Version
12.13.0
Cumulative downloads
Total Downloads
Last day
0%
6
Compared to previous day
Last week
20%
6
Compared to previous week
Last month
8.3%
13
Compared to previous month
Last year
-9.4%
164
Compared to previous year
19
使用 vue 的 keep-alive 和 transition 组件对路由进行快捷的动画和缓存设置。
1npm i vue-router-cache-animate 2yarn add vue-router-cache-animate
main.js
1import Vue from 'vue' 2import router from './router' 3import vueRouterCacheAnimate from 'vue-router-cache-animate' 4 5// 提供的移动端 slide-left、slide-right 动画,也可以自定义 6import 'vue-router-cache-animate/dist/css/animate.css' 7Vue.use(vueRouterCacheAnimate, { router })
App.vue
1<template> 2 <div id="app"> 3 <vue-router-cache-animate :caches="caches" :transitions="transitions"> 4 <router-view /> 5 </vue-router-cache-animate> 6 </div> 7</template> 8<script> 9export default { 10 data() { 11 return { 12 caches: [ 13 { 14 // 路由 name 和路由组件的 name(需保证相同) 15 names: { 16 include: ['A'], 17 exclude: undefined 18 }, 19 // 在哪些路由上被缓存 20 cachedOn: { 21 include: ['B', 'C'], 22 exclude: undefined 23 } 24 } 25 ], 26 transitions: [ 27 { 28 name: 'slide-left', 29 reverseName: 'slide-right', 30 from: { 31 // 路由 name 32 include: ['A'], 33 exclude: undefined 34 }, 35 to: { 36 // 路由 name 37 include: ['B', 'C'], 38 exclude: undefined 39 } 40 } 41 ] 42 } 43 } 44} 45</script>
缓存设置。
类型:Array
默认值:
1{ 2 names: {}, 3 cachedOn: {} 4}
默认缓存所有路由。
示例:
1export default { 2 data() { 3 return { 4 caches: [ 5 { 6 // 路由 name 和路由组件的 name(需保证相同) 7 names: { 8 include: ['A'] 9 // exclude: [] 10 }, 11 // 在'B', 'C'路由上缓存路由组件 A 12 cachedOn: { 13 include: ['B', 'C'] 14 // exclude: [] 15 } 16 }, 17 { 18 names: { 19 include: ['B'] 20 }, 21 // 在 'C' 路由上缓存路由组件 B 22 cachedOn: { 23 include: ['C'] 24 } 25 } 26 ] 27 } 28 } 29}
除了使用 include
包含,还可以使用 exclude
排除。
动画设置。
类型:Array
默认值:[]
示例:
1export default { 2 data() { 3 return { 4 transitions: [ 5 { 6 // transition 组件的 name 选项 7 // 从 'A' 路由到 'B', 'C' 路由使用 'slide-left' 动画 8 name: 'slide-left', 9 // 'B', 'C' 路由到 'A', 使用 'slide-right' 动画 10 reverseName: 'slide-right', 11 from: { 12 // 路由 name 13 include: ['A'] 14 // exclude: [] 15 }, 16 to: { 17 // 路由 name 18 include: ['B', 'C'] 19 // exclude: [] 20 } 21 } 22 ] 23 } 24 } 25}
后退时,是否缓存路由。
Boolean
false
后退的情况:
history.go(-n)
或者 history.back()
。router.go(-n)
或者 router.back()
。实现像手机端 app 一样前进刷新,后退缓存的效果。
路由切换时,会自动缓存前一个路由。当 后退 时,不缓存当前路由,这样当再次前往该路由时,会重新生成。
1export default { 2 data() { 3 return { 4 noCacheOnBack: true 5 } 6 } 7}
当使用
history.pushState(state, title, path)
和history.replaceState
时,需要设置state
为一个对象,并提供一个唯一key
属性。例如:
1history.pushState( 2 { 3 key: new Date() + Math.random() 4 }, 5 title, 6 path 7)
这个
key
会被用来判断浏览器是前进还是后退。
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/10 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
96 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More