1.配置路由缓存 router.js文件或router文件夹下的index.js文件
routes: [
{
path: '/hello',
name: 'HelloWorld',
component: HelloWorld,
meta: {
keepAlive: true // 需要缓存false//不需要缓存
}
}
]
2.配置App.vue文件种的<router-view/>
<keep-alive>
<router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive"></router-view>