当前位置: 代码迷 >> 综合 >> keep-alive 新增的两个函数 activated deactivated,以及include exclude
  详细解决方案

keep-alive 新增的两个函数 activated deactivated,以及include exclude

热度:108   发布时间:2023-09-14 17:35:23.0
include:缓存;
exclude:不缓存;
<keep-alive include="test-keep-alive"><!-- 将缓存name为test-keep-alive的组件 --><component></component>
</keep-alive><keep-alive include="demoA,demoB"><!-- 将缓存name为a或者b的组件,结合动态组件使用 --><component :is="view"></component>
</keep-alive><!-- 使用正则表达式,需使用v-bind -->
<keep-alive :include="/demoA|demoB/"><component :is="view"></component>
</keep-alive><!-- 动态判断 -->
<keep-alive :include="includedComponents"><router-view></router-view>
</keep-alive><keep-alive exclude="test-keep-alive"><!-- 将不缓存name为test-keep-alive的组件 --><component></component>模块缓存后悔新增两个方法activated (进入页面时调用)deactivated(离开页面时调用),主要实现方式是监听路由变化
  相关解决方案