曹え 5811 发布于:2022-04-19 03:38:11
引入
import { useRouter } from 'vue-router' const router = useRouter()
常用
// 跳转 router.push('/home') // 传参数 router.push({ path:"/details", query:{group_id: data2.group_id} }) // 获取url传递的参数 const urlVal = router.currentRoute.value.query; let pidq = urlVal.pid;
router/index.js
包含母版
import { createRouter, createWebHistory } from 'vue-router' import HomeView from '../views/HomeView.vue' const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), routes: [ { path: '/', name: 'home', component: HomeView, children: [ { path: '/', component:() => import('../views/Home/Index.vue'), }, { path: '/about', name: 'about', component: () => import('../views/Home/About.vue') }, { path: '/wang', name: 'wang', component: () => import('../views/Home/Wang.vue') } ] }, { path: '/login', name: 'login', component: () => import('../views/Login.vue') } ] }) export default router
登录后可以留言提问!
微信扫码登录