import { useRouter } from "vue-router";
const router = useRouter();
//解决进入页面数据不是最新问题
let previousRouteName = router.currentRoute.value.name;
watchEffect(() => {
const currentRouteName = router.currentRoute.value.name;
if (currentRouteName !== previousRouteName) {
// 如果当前路由名称与上一次不同,执行页面刷新逻辑
previousRouteName = currentRouteName; // 更新上一次的路由名称
这个判断里边可以写各种方法,例如:刷新浏览器、调用接口等等
handleList(); //列表接口方法:这里写的是重新调用接口的方法
}
});
07-11
220
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-12
1707
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交