动态组件、缓存、activate钩子
程序员文章站
2022-06-01 19:46:21
...
<template>
<component :is="currentView"></component>
<!-- 动态组件缓存 -->
<keep-alive>
<component :is="currentView">
</component>
</keep-alive>
</template>
<script>
data(){
return{
//通过动态变化currentView来实现动态模块的功能
currentView: 'v-home1',
}
},
activated() {
console.log('activate called')
setTimeout(() => {
console.log('activate done');
}, 100);
}
</script>
推荐阅读