vue----keep-alive缓存,activated,deactivated两个生命周期函数,,meta实现缓存

2019-12-14 21:06:58

参考地址 vue----keep-alive缓存,activated,deactivated两个生命周期函数,,meta实现缓存

keep-alive缓存(一般都要将首次创建的组件缓存,提高性能

    

复制代码

将需要缓存的组件缓存在内存当中,下次再次访问的时候,直接从缓存中读取,而不是重新创建或者销毁……提高了性能

(<keep-alive>
       <component :=></component>
</keep-alive>

复制代码

 

keep-alive对应两个生命周期,activated(){}    deactivated(){}

 

复制代码

当从缓存中读取a组件时,此时a组件处于活跃状态,
当从缓存中读取b组件时,a组件处于缓存状态,此时b组件处于活跃状态,
 用途:
    eg:当在a组件浏览小说到某个位置,这时,我切换到b组件,那么就用a组件的缓存状态函数记录这个位置(),
当我再次切换到a组件,用活跃状态函数 保存到该位置        activated(){    console.log(
"活跃状态"); },deactivated(){    console.log("缓存状态") }

复制代码

 利用include,exclude属性

复制代码

include属性表示


<keep-alive include=>
      <router-view></router-view>
</keep-alive>
<keep-alive exclude=>
      <router-view></router-view>
</keep-alive>

复制代码

利用meta属性

复制代码

export <keep-alive> 
 </keep-alive>



  • 2017-11-10 00:06:15

    CORS: credentials mode is 'include'

    XMLHttpRequest cannot load http://localhost/Foo.API/token. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:5000' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

  • 2017-11-19 00:17:51

    Java如何获取Date的“昨天”与“明天”示例代码

    最近在做项目的时候用到Date和Calendar比较多,而且用到的方式也比较全,突然想到一个问题,Java如何获取Date的"昨天"与"明天",也就是前一天和后一天呢?思考后写出了方法,想着万一以后用到,就总结出来,也方便有需要的朋友们参考借鉴,下面来一起看看吧。