vue keep-alive 指定某个组件保留缓存

keep-alive 指定某个组件保留缓存使用include

 <button @click="isflag='btn'"></button>
 <button @click="isflag='btn2'"></button>
  <keep-alive include="btn2">
       <component :is="isflag"></component>
  </keep-alive>
这里 component :is 动态组件 ,include =btn2 给btn2组件添加缓存若不指定都缓存

 <keep-alive exclude="btn2">
            <component :is="isflag"></component>
 </keep-alive>
exclude 不需要给某个组件添加缓存
原文地址:https://www.cnblogs.com/youmingkuang/p/15148045.html