编程式路由
import { getCurrentInstance } from "vue";
const { proxy } = getCurrentInstance();
// 编程式路由
proxy.$router.push({ path: "/path" }); // 使用path/name都可以 name 不必和 path 相同 可以当作 id 一样
//proxy.$router.push({ name: "/PATH" });
假设这是你的路由表
{
name: "PATH",
path: "/path",
component: () => import("@/views/path(.vue)")
// 使用 vite创建项目 才会添加 .vue
}