keeplive的使用
生活随笔
收集整理的這篇文章主要介紹了
keeplive的使用
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
視圖組件加載位置
/**max最大緩存頁(yè)面數(shù)*/<keep-alive max="5">/** 需要緩存的視圖組件*/<router-view v-if="$route.meta.keepAlive" ></router-view></keep-alive>/** 不需要緩存的視圖組件 */<router-view v-if="!$route.meta.keepAlive"></router-view>路由里
{path: 'index',name: 'index',component: () => import(/* webpackChunkName: 'home'*/"@/views/home/index/index.vue"),},//路由懶加載以及webpackChunk配置meta: {keepAlive: true,title: '首頁(yè)'} }keep-alive的生命周期
activated: 頁(yè)面第一次進(jìn)入的時(shí)候,鉤子觸發(fā)的順序是created->mounted->activated deactivated: 頁(yè)面退出的時(shí)候會(huì)觸發(fā)deactivated,當(dāng)再次前進(jìn)或者后退的時(shí)候只觸發(fā)activated可以通過(guò)路由守衛(wèi)動(dòng)態(tài)更改緩存值得狀態(tài) vue-router提供了三個(gè)鉤子,beforeRouterEnter、beforeRouterUpdate、beforeRouteLeave。 beforeRouterEnter(to,from,next){ next(vm=>{}) }總結(jié)
以上是生活随笔為你收集整理的keeplive的使用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: G502使用计算机配置,罗技G502鼠标
- 下一篇: 观点:我们为什么需要威胁情报?