vue3 axios中使用router进行跳转

在axios文件中导入router,console输出为undefined
(js/ts中无法使用vue声明的文件/不能使用useRouter ,useRoute,他们需要在setup中调用执行后才能用)

解决方法(推荐)

导入项目中已配置好的router

import router from '@/router'

其他方法

window.location.href = "/login"

原文链接:https://blog.csdn.net/AIB_Kasic/article/details/123790657

posted @ 2022-05-25 12:11  黑蛋的博客  阅读(1622)  评论(0编辑  收藏  举报