1、在app中设置需要缓存的div
<keep>//缓存的页面
<router v-if=$route.meta.keepAlive></router>
</keep>
<router v-if=!$route.meta.keepAlive></router>//不缓存的页面
2、在路由router.js中设置.vue页面是否需要缓存
{
path: '/home',
component: home,
meta: { keepAlive: true },//当前的.vue文件需要缓存
},
{
pa