// router的配置
{
path: "list",
meta: {
title: "商品列表",
keepAlive: true //表示需要缓存
},
component: () => import("@/views/product/list/index")
}
// app.vue配置
<template>
<div>
<keep-alive>
<router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive"></router-view>
</div>
</template>