fix: fix keepAlive not work

This commit is contained in:
vben
2020-12-05 09:30:51 +08:00
parent 4cca007176
commit b884654761
6 changed files with 14 additions and 15 deletions

View File

@@ -45,7 +45,7 @@ export default defineComponent({
const renderComp = () => <Component key={route.fullPath} />;
const PageContent = unref(openCache) ? (
<KeepAlive>{renderComp()}</KeepAlive>
<KeepAlive include={cacheTabs}>{renderComp()}</KeepAlive>
) : (
renderComp()
);

View File

@@ -35,17 +35,18 @@ export function useCache(isPage: boolean) {
// not parent layout
return cached.get(PAGE_LAYOUT_KEY) || [];
}
const cacheSet = new Set<string>();
cacheSet.add(unref(name));
const list = cached.get(unref(name));
if (!list) {
return Array.from(cacheSet);
}
list.forEach((item) => {
cacheSet.add(item);
});
return Array.from(cacheSet);
});
return { getCaches };