li标签 click执行change_game ,当当前路由不变的时候就刷新 const change_game = (item) => { game_active.value = item.id; router.push({ name: "gameIndex", query: { g: game_active.value } }); };
const change_game = (item) => { if (router.currentRoute.name === "gameIndex" && router.currentRoute.query.g === item.id) { router.go(); // 刷新当前页面 } else { game_active.value = item.id; router.push({ name: "gameIndex", query: { g: game_active.value } }); } };
// 如果当前路由名称为 gameIndex,并且路由参数 g 与当前点击的游戏 id 相同,则刷新当前页面;否则,执行切换游戏的操作。
原文地址: https://www.cveoy.top/t/topic/fSl 著作权归作者所有。请勿转载和采集!