fix: tab-router refresh fail (#289)

This commit is contained in:
yuyang 2022-09-03 22:15:00 +08:00 committed by GitHub
parent 3bf20b4eea
commit 83cc3d7e90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -114,10 +114,10 @@ export default defineComponent({
const route = tabRouters.find((i) => i.path === path); const route = tabRouters.find((i) => i.path === path);
router.push({ path, query: route.query }); router.push({ path, query: route.query });
}; };
const handleRefresh = (route: TRouterInfo) => { const handleRefresh = (route: TRouterInfo, routeIdx: number) => {
tabsRouterStore.toggleTabRouterAlive(route.routeIdx); tabsRouterStore.toggleTabRouterAlive(routeIdx);
nextTick(() => { nextTick(() => {
tabsRouterStore.toggleTabRouterAlive(route.routeIdx); tabsRouterStore.toggleTabRouterAlive(routeIdx);
router.replace({ path: route.path, query: route.query }); router.replace({ path: route.path, query: route.query });
}); });
}; };
@ -198,7 +198,7 @@ export default defineComponent({
dropdown: () => dropdown: () =>
router.path === route.path ? ( router.path === route.path ? (
<t-dropdown-menu> <t-dropdown-menu>
<t-dropdown-item onClick={() => handleRefresh(router)}> <t-dropdown-item onClick={() => handleRefresh(router, idx)}>
<t-icon name="refresh" /> <t-icon name="refresh" />
</t-dropdown-item> </t-dropdown-item>