import {createRouter, createWebHashHistory} from 'vue-router'
const routes = [
{
path: "/",
component: () => import(""),
children: [
{
path: "/",
redirect:'/home'
},
{
path: "/home",
name: "home",
component: () => import("@/pages/home"),
}
]
},
]
const router = createRouter({
history: createWebHashHistory(),
routes
})
export default router
使用
import {useRouter} from "vue-router";
import router from 'router'
// 或
const router = useRouter();
// 获取
router.currentRoute.value.name
// 跳转
router.push("");