vue中的keep-alive配合beforeRouteLeave做动态缓存

{ // 建筑记录
path: ‘jz/illegal’,
component: () => import(’@/views/AI/jz/illegalRecord/index.vue’),
meta: {
keepAlive: true
}
}

beforeRouteLeave(to, from, next) {
if (to.name === “illegalRecordDetail”) {
from.meta.keepAlive = true;
} else {
from.meta.keepAlive = false;
}
next();
}

如上面的在利用beforeRouteLeave动态的修改组件当中的 meta.keepAlive 的值时,保存的状态是上次的, 不是当前的组件状态, 请问有知道怎么解决的吗?