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 不需要给某个组件添加缓存

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-22
  • 2021-10-29
  • 2021-12-02
  • 2021-07-31
  • 2021-10-27
猜你喜欢
  • 2021-11-23
  • 2021-10-09
  • 2021-10-22
  • 2022-12-23
  • 2022-12-23
  • 2021-04-15
  • 2021-09-22
相关资源
相似解决方案