Browse Source

使用keep-alive.include清除非tabs标签页缓存的路由组件

master
wanggang 1 year ago
parent
commit
3f9342d331
  1. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/layouts/index.js
  2. 6
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/index.js

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/layouts/index.js

@ -21,7 +21,7 @@ export default {
<el-main>
<router-view v-if="!isRefreshing" v-slot="{ Component, route }">
<component :is="Component" v-if="route.meta?.disableCaching" :key="$route.fullPath" />
<keep-alive>
<keep-alive :include="appStore.routes.map(o=>o.path)">
<component :is="Component" v-if="!route.meta?.disableCaching" :key="route.fullPath" />
</keep-alive>
</router-view>

6
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/index.js

@ -117,7 +117,11 @@ const refreshRouter = async () => {
}
if (o.component.constructor === String) {
const name = o.component;
o.component = () => import(`../views${name}.js`);
o.component = async () => {
const module = await import(`../views${name}.js`);
module.default.name = name;
return module.default;
};
}
}
// children

Loading…
Cancel
Save